Aug 31, 2015, 3:51 PM
Is there a way to define conditional rendering based on ternary operator on tpl templates?
I would like to know how to use ternary operator on tpl within a dataview using razor engine
I would like to add something like
Any idea of how to use ternary conditions or an alternative that may look like that?
(i dont want to copy/paste the same layout within an "else block" just to change a thing)
.Store(X.Store()
....
).Tpl(@<text>
<tpl for=".">
<div class="holder">
<div class="avatar"></div>
<div class="h-content">
<h2>{Name}</h2>
<h3>{Phone} {Extension}</h3>
<p>{Position} {CompanyName}</p>
</div>
</div>
</tpl>
</text>)
)
I would like to add something like
<div class="holder {[condition == true ? 'classA':'classB']}">
....
</div>
I've tried that way but as soon as the code is rendering that componet it just stops at the very first element.Any idea of how to use ternary conditions or an alternative that may look like that?
(i dont want to copy/paste the same layout within an "else block" just to change a thing)