kirbysayshi / vash

Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates
Other
524 stars 60 forks source link

Conditions inside templates #121

Closed stelonix closed 6 years ago

stelonix commented 6 years ago

Since documentation seems to be vague, I'm not sure whether I've missed it... Is it not possible to use conditionals inside @ blocks? Eg. in below example:

@model.trabalhos.forEach(function(t) {
<span class="bg">
    <span>@t.data.dia de @model.meses[t.data.mes-1] de @t.data.ano</span>
    <p>@t.nome</p>
@if (typeof t.desc !=== null) {
    <p>@t.desc %></p>
} else {
    <p class="b">@t.tipo - @t.farda</p>
}
</span>
})

I'm getting some kind of infinite recursion error. Is this not at all supported by the engine? if it isn't, how do I achieve a similar goal using vash? Error below:

SyntaxError: Problem while rendering template at line 0, character 0. Original message: Problem while compiling template at line 0, character 0. Original message: Unexpected token =.

stelonix commented 6 years ago

It was actually a syntax error on my side, too many '='