Field name in reusable macro I'm creating a macro I'd like to reuse multiple times but the only thing that changes is the field name (matrix). Here's an example:

{% for block in entry.fieldname1 %}
&lt;h3&gt;{{ block.title }}&lt;/h3&gt;


I'd like to increment this macro so I don't rewrite this code snippet over and over again but when I try and change entry.fieldname1 to a string it's no{% set string = entry.fieldname ~ 1 %} it is no longer recognized inside the for loop.

Any ideas?
Try using an array syntax instead of the object syntax:

{% set string = entry['fieldname' ~ 1] %}