Crate yew_lmth

source ·
Expand description

§Yew Lmth

A macro crate for writing HTML-like syntax, which will be translated into a corresponding yew::prelude::html!() macro.

§Syntax

§Tags

lmth! syntaxmeaninghtml! syntax
! { ... }Yew’s fragment<> ... </>
@{expr} { ... }Dynamicly named tag<@{expr}> ... </@>
tag (attrs) { ... }Tag with attributes and content<tag attrs>{ ... }</tag>
tag (attrs)Void tag with attributes<tag attrs />
tag { ... }Tag with content<tag>{ ... }</tag>
tagVoid tag with no attribute<tag />

§Attributes

Attributes are separated by commas: tag (attr: val, attr: val, ...) { ... }

lmth! syntaxmeaninghtml! syntax
attr: exprAttribute with expression as valueattr={expr}
attr: {code}Attribute with code block as valueattr={code}
attr="litstr"Attribute with literal string as valueattr="litstr"
attrShorthand for {attr} in yew{attr}

§Content

lmth! syntaxmeaninghtml! syntax
{code}Code as content{code}
"litstr"Literal string as content"litstr"
tag ...Tagcorresponding tag

§Conditional rendering

lmth! syntaxmeaninghtml! syntax
if {code} { ... }Conditional renderingif {code} { ... }
if let {code} { ... }Conditional renderingif let {code} { ... }

Macros§

  • Macro for writing HTML-like syntax. It works by translating it into a corresponding yew::prelude::html!() macro.