Announcement

Collapse
No announcement yet.

Variables and Functions In Templates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Variables and Functions In Templates

    Is there any way of declaring a variable inside a Template?

    For example, if I wanted to increment a running counter for records, it would be quite nice if I could do something like:

    {{#var counter}}
    ...
    {{counter++}}

    Likewise, if I wanted to sum up a number of fields (i.e. a weight field) and then display the total in the Template footer.

    Can this be done in the Template (rather than in the Entity as a formula)?

  • #2
    No. Templates very restricted in abilities. The lib we use doesn't give any room for enhancing.

    Comment


    • #3
      yuri Ok, no problemo.

      Comment


      • #4
        I think that should work,but if you already have a customview you could just sum up the weights before giving the conext to the template.
        PHP Code:
         HandleBars.registerHelper("counter",function(root){root.weightSum += this.weight}); 
        HTML Code:
        <table>
        {{#each heavyThings}}
        {{counter @root}}
        <tr><td>{{name}}</td><td>{{weight}}</td><(tr>
        {{/each}}
        </table>
        <footer>
        {{weightSum}}
        </footer>
        Last edited by Andorxor; 09-26-2019, 11:52 AM.

        Comment

        Working...
        X