HTML Script of type text/html - templates

if-statement, jquery, syntax, template-engine

Solution

You would have to use `else`:

{{if condition}}

{{else}}

{{/if}}

http://api.jquery.com/template-tag-else/

Problem

I came across this code in a website I am maintaining: ``` <script type="text/html" id="searchList"> <li class="listing ${ $data.EvenOdd }"> {{if $data.DisplaySaleTag }} {<span class="price">${ $data.Price }</span>} {{/if}} </li> </script> ``` I read on another post that a script tag of `type="text/html"` is not recognized by browsers and so they are ignored, and that it is probably used by a javascript templating engine. I pretty sure it is using this template API (correct if I'm wrong). Anyway, I need to modify this code to be (say C# syntax) `if(!$data.DisplaySaleTag)`, but `{{if !$data.DisplaySaleTag }}` is not working. How can I code a `not` into this `if` statement? Is there any documentation for this template API code? It seems so foreign..

Original source