I've been using jsviews to link and render some templates. In one of my template, I have the following {{if}}
condition.
<script id="listTmpl" type="text/x-jsrender">
{{if content_type.indexof('IMG_') >= 0 }}
<span class="content-img-preview" data-src={{:distURL}}></span>
{{else}}
''
{{/if}}
</script>
Where content_type is a string that can can be like 'IMG_201_345'.
However, the indexof()
function does not work. How else can I check if the string contains the pattern 'IMG_' using the {{if}}
condition?
If I use indexof
my code return:
Error: Object IMG_201_345 has no method 'indexof'.
by using indexOf
is working fine.