skip to Main Content

is there a way in twig to echo a variable in literals, like this?

{{ mb.get_the_post_thumbnail( post.ID, 'full', {'class': 'sec-mitarbeiter-image {{objectPositionClass}} '} ) }}

Result:

class="sec-mitarbeiter-image {{objectPositionClass}}"

Expected:

class="sec-mitarbeiter-image object-position-top"

2

Answers


  1. Try this

    {{ mb.get_the_post_thumbnail( post.ID, 'full', {'class': `sec-mitarbeiter-image $objectPositionClass `} ) }}
    
    
    Login or Signup to reply.
  2. I guess you want simple string concatenation:

    {{ mb.get_the_post_thumbnail(post.ID, 'full', {
        'class': 'sec-mitarbeiter-image ' ~ objectPositionClass
    }) }}
    

    Or interpolation:

    {{ mb.get_the_post_thumbnail(post.ID, 'full', {
        'class': "sec-mitarbeiter-image #{objectPositionClass}"
    }) }}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search