Under heavy research and development, please don't use this yet!
Simple node tree abstraction layer over RSX syntax trees
A backwards compatible higher level of abstraction over the AST generated by the RSX parser. Since working directly with rsx_parser::RSXElement
abstract syntax trees (or Rust's proc_macro::TokenStream) can be tedious, and the underlying parser and compiler data formats can change at any time, a simpler DOM structure is useful as an abstraction layer in the scope of writing RSX code.
This crate concerns itself strictly generating a DOM node tree from a RSX syntax tree. If you're just looking to write RSX in your project, take a look at the RSX compiler plugin instead.
Otherwise, add this to your Cargo.toml
file:
[dependencies]
rsx-dom = { git = "https://github.com/victorporof/rsx-dom.git" }
RSX parsing is enabled via the rsx-parse
feature gate.
[dependencies]
rsx-dom = { git = "https://github.com/victorporof/rsx-dom.git", features = ["rsx-parse"] }
When used as part of the RSX compiler plugin, the convertion is automatic between rsx_parser::RSXElement
abstract syntax trees to the more convenient rsx_dom::DOMNode
elements, because the AST is directly tokenized into a DOM tree to avoid any runtime work! Templating is thus a zero cost abstraction.
If manual instantiation is desired, simply import the library into your code to build rsx_dom::DOMNode
elements.
extern crate rsx_dom;
use rsx_dom::types::DOMNode;
let node = DOMNode::from(...);
Note that when used as a compiler plugin,
Note: rsx-dom
also re-exports the rsx-parser
crate, only needed if you need to parse character streams (such as strings) directly. You'll probably prefer using the rsx!
macro as part of the RSX compiler plugin instead.
See all the available types for more details.