syn-powered parser for JSX-like TokenStreams
Node
was converted to an enum
similar to syn
's Expr
. This was primarily done because the old API required manual documentation lookups to decide whether it is safe to unwrap a node name or value based on the Node::node_type
. This is not really type safe or rusty, and hence the decision was made to move to a type safe API. There's also no measurable impact on performance. If you have feedback or concerns regarding this change, feel free to voice them in https://github.com/stoically/syn-rsx/issues/26.
Basically,
match node.node_type {
NodeType::Element => node.name_as_string().unwrap(),
NodeType::Attribute => node.name_as_string().unwrap(),
NodeType::Text => node.value_as_string().unwrap(),
...
}
becomes
match node {
Node::Element(element) => element.name.to_string(),
Node::Attribute(attribute) => attribute.key.to_string(),
Node::Text(text) => String::try_from(&text.value).unwrap(),
...
}
NodeName::span
was dropped, since NodeName
already implements syn::spanned::Spanned
, which gives you the span
method if you import the trait accordingly.
NodeName::Colon
and NodeName::Dash
were merged into NodeName::Punctuated
. This was done to allow attribute names like on:some-event
. Thanks @gbj for working on it. (#34)
See CHANGELOG
See CHANGELOG
See CHANGELOG
Cargo.lock
BREAKING
NodeType
and NodeName
enum variantsParserConfig
no longer implements Clone
and Debug
Features
transform_block
configuration which takes a closure that receives raw block content as ParseStream
and lets you optionally convert it to a TokenStream
. That makes it possible to have custom syntax in blocks. More details in #9BREAKING
NodeName
enum variantFeatures
BREAKING
NodeType
enum variantsParserConfig
no longer implements Clone
and Debug
Features
transform_block
configuration which takes a closure that receives raw block content as ParseStream
and lets you optionally convert it to a TokenStream
. That makes it possible to have custom syntax in blocks. More details in #9Features
span
method on NodeName
Fixes
number_of_top_level_nodes