Meteor Blaze Template - Dynamic field name

I’m passing the arguments field1 and field2 to a blaze template and I would like to use them to get an object property inside that template.

For example:

field1 = "name", field2 = "total"

<h5 class="card-item-name">{{this[field1]}}</h5>
<span class="card-item-total">{{this[field2]}}</span>

Instead of:

<h5 class="card-item-name">{{}}</h5>
<span class="card-item-total">{{}}</span>

How can I do this?

You’ll have to use a helper:

<h5 class="card-item-name">{{thisField field1}}</h5>
<span class="card-item-total">{{thisField field2}}</span>
  thisField(fieldName) {
    return this[fieldName]