'Injecting variable into attribute in MPTS

I tried to make template using MPTS and it works for this h2, but I cannot inject attribute for img

<div>
   <h2>{{user.name}}</h2>
   <img src="user.avatar" class="avatar" />
</div>

I also tried <img src="{{user.avatar}}" class="avatar" /> but it also doesn't work.



Solution 1:[1]

To inject a variable as an attribute you need to ommit quotes. Quotes means to threat it as a string.

<img src=user.avatar class="avatar" />

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mateusz Krawczyk