5 ms·
I'd love for them to adopt something similar to Razor (Microsoft server side html engine) note: i've changed your example to show code inside html tags, i'm aw
by _betty_ 10y ago
I'd love for them to adopt something similar to Razor (Microsoft server side html engine)
note: i've changed your example to show code inside html tags, i'm aware it does something different to yours.
conditionals
<div>
@if(cond1 && cond2) {
<div>foo</div>
}
</div>
loops
<div>
@for(var i in collection) {
<div></div>
}
</div>
variables
<div>
@variable
</div>
ternary/longer statement
<div>
@(variable ? 1 : 2)
</div>
- tmzt 10y agoThe one negative thing I've found with Razor is the ambiguous start and end of statements or expressions vs html. Sometimes a @ is required before a statement and sometimes its a syntax error, conversely statements and and expressions may be rendered as text if they follow html with a @. I think jsx's approach is clearer.
- _betty_ 10y agoadmittedly there is the occasional moment I hit where I need an extra @ or @: so it's not perfect, but I have much less issue reading that format than the { true && <element /> } syntax, also think @if is a lot nicer than <if>. Maybe just a personal thing.