문제

Is it possible in HAML to create variable TAGs as the subject asks?

Want to do

- tag = "h1"


%tag

Cheers

Final Version I used was

-# Type Default
- if ! defined? locals[ :type ]
    - type = "h1"
- else
    - type = locals[ :type ]

-# Heading
- haml_tag type do

    -# Main Text
    = locals[:text]

    -# Add the secondary text if required
    -if defined? locals[ :small ]
        %small= locals[ :small ]
도움이 되었습니까?

해결책

Yeah, it's possible.

Try this.

- tag = 'h1'
- haml_tag tag, "I'm h1."
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top