Ok, so I'm trying to use an "if" statement within my javascript. Depending on a boolean in my model, a function should return some html or an empty string. This is basically what I want to do:
function getSomeHtml() {
var myHtml = '';
@if(Model.UseSomeNiceHtml)
{
<text>
myHtml += '<div> <p class="label">Whatever</p></div>';
</text>
}
return myHtml;
}
Similar code works really well when using a foreach loop (basically replacing if with foreach in the example above). With the if statement I get the error "Encountered end tag "text" with no matching start tag. Are your start/end tags properly balanced?". When I remove the <text> tags I get the error "Too many characters in character literal".
Could anyone point me in the right direction?
Thank you! :)
<text>tags? It looks like theifstatement just determines if themyHtmlshould ba altered or not. If that's the case I don't see the point of the `<text>´ tags.<text>tag?