4 ms·
I wonder if there is a way to write a macro library that can use regular `if` and `for` instead of `$if` and `$for`.
by ufo 11y ago
I wonder if there is a way to write a macro library that can use regular `if` and `for` instead of `$if` and `$for`.
- eridius 11y agoThis is a syntax extension, so it's consuming the tokens directly. It could in fact do that if it wanted to. But it appears that the grammar of the template engine treats bare identifiers as tag names, which is why it uses the nonterminal tokens $if, etc for keywords.
- allan_s 11y agoif you write a syntax extension, you can use if and any other rust keywords / operator / token (see the template language i started which use if directly)
- nimrody 11y agoThe one thing I like about React's JSX "html in javascript", is that it lets you reuse all of the host language (javascript in React's case) control structures. Otherwise Maud has to re-implement if/then/else, iterator methods, etc. But perhaps you could use 'if/then' and other structures inside a $() block.