there is a code snippet of the following form:

-if true %foo .container %a(href='#') -else %bar .container %a(href='#') 

How can you shorten this entry so that the foo and bar tags change depending on the condition, but you would not have to write their contents twice?

    1 answer 1

    In the HAML implementation in Ruby, you can do this via the haml_tag helper :

     - haml_tag(true ? "foo" : "bar") do .container %a(href='#') 

    In the HAML language itself, the resolution of such situations is not provided; it is at the mercy of the executable code in the templates.

    • @KirillStronko, or the examples in the documentation are incorrect, or something is wrong on your side. I'm afraid I do not have the opportunity to check both options now. - D-side
    • figured out my glitch. all right, thank you :) - Cyril Stronko
    • @ KirillStronko please tick :) - D-side