How to render twig variable as HTML attribute name

271 views Asked by At

I am trying to set a custom HTML attribute name using twig, trying to achieve this:

<div age="24"> Something </div>

This is my code:

{% set custom_age_attribute= "age" %}
<div {{custom_age_attribute}}="24"> Something </div>

But the twig code is not rendering and getting this:

<div {{custom_age_attribute}}="24"> Something </div>

Is there any way to make it work?

0

There are 0 answers