Search code examples
web2pydelimiterjquery-templates

Is there a way to use a conditional with this updated jQuery template delimiter?


I am new to jQuery templates and changed the delimiters from {{ }} to {% %} because web2py uses {{ }}. This worked until I needed a conditional in the 'each columns' loop below

Is there an easy way or workaround to use the following 'if statement' with the {% %} delimiter?

The following results with the error: Unexpected Token: %=

<script id="itemDetailsTemplate" type="text/x-jquery-tmpl">
  <div class='item-details-form'>
    {%each columns%}
        {%if ${id} != 'index_block'%}
            <div class='item-details-label'>
              ${name}
            </div>
            <div class='item-details-editor-container' data-editorid='${id}'></div>
        {%/if%}
    {%/each%}
</script>

Solution

  • It looks like you need

    {%if id != 'index_block'%}

    rather than

    {%if ${id} != 'index_block'%}