join - Appending a text to a variable in Twig -
I am trying to insert a string using the ~ (tild) operator in the trigger. This is my case, I have many different things with:
{% set class = 'original_text'%} {try first: the most obvious for me, the form of PHP God # {% Class ~ = 'some_other_text'%} {try for # seconds} {% class = class ~ 'some_other_text'%} {# third attempt #} {% class = [class, 'some_other_text'] | Join (''%} {# Fourth Attempt: Existing Variable has been changed #} {% set class = [class, 'some_other_text'] |
In any of the above mentioned tasks Is not included.
I need to add some text and every time some text is added. Something like this will work in this way:
{% set class = 'Original_text'%} {% class ~ = 'first_append'%} {% class ~ = 'second' exception '%} {% class ~ =' third_append '%}
and more
{{class}}
will result in:
original_text first_ append second Any ideas on how to do this? Thanks!
Edit: CSS error proved, concatenation went well ....
using the set tag You can add a string with one variable, from your example we can rewrite the lines,
{% set class = 'original_text'%} {% set class = class} 'Some_other_text'%}
and we can print out such new class variable ,
{{class}}
show it out showing this way, original_text_dh_my_text
Comments
Post a Comment