"The tool company for tool companies"
{ (0..3).map(|_| html!(">o_o<"
)) }"Every company should be a developer experience company"
); let doc_str = doc.to_string(); ``` ## Syntax This macro largely follows [JSX] syntax, but with some differences: * Text nodes must be quoted, because there's only so much Rust's tokeniser can handle outside string literals. So, instead of `Hello
`, you need to write `"Hello"
`. (The parser will throw an error asking you to do this if you forget.) * Element attributes will accept simple Rust expressions, but the parser has its limits, as it's not a full Rust parser. You can use literals, variables, dotted properties, type constructors and single function or method calls. If you use something the parser isn't currently capable of handling, it will complain. You can put braces or parentheses around the expression if the parser doesn't understand it. You can use any Rust code inside a brace or parenthesis block. ## Valid HTML5 The macro will only accept valid HTML5 tags, with no tags or attributes marked experimental or obsolete. If it won't accept something you want it to accept, we can discuss it over a pull request (experimental tags and attributes, in particular, are mostly omitted just for brevity, and you're welcome to implement them). The structure validation is simplistic by necessity, as it defers to the type system: a few elements will have one or more required children, and any element which accepts children will have a restriction on the type of the children, usually a broad group as defined by the HTML spec. Many elements have restrictions on children of children, or require a particular ordering of optional elements, which isn't currently validated. ## Attribute Values Brace blocks in the attribute value position should return the expected type for the attribute. The type checker will complain if you return an unsupported type. You can also use literals or a few simple Rust expressions as attribute values (see the Syntax section above). The `html!` macro will add an [`.into()`][Into::into] call to the value expression, so that you can use any type that has an [`Into`][Into] trait defined for the actual attribute type `A`. As a special case, if you use a string literal, the macro will instead use the [`FromStr`][FromStr] trait to try and parse the string literal into the expected type. This is extremely useful for eg. CSS classes, letting you type `class="css-class-1 css-class-2"` instead of going to the trouble of constructing a [`SpacedSet"Hello Axo"
); let doc_str = doc.to_string(); assert_eq!("Hello Axo
", doc_str); ``` ### Render to a virtual DOM The DOM tree structure also implements a method called `vnode()`, which renders the tree to a tree of [`Node`][Node]s, which is a mirror of the generated tree with every attribute value rendered into `String`s. You can walk this virtual DOM tree and pass it on to your favourite virtual DOM system. ## License This software is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at