在HAML中是否可以按照受试者的要求创建变量TAG?
想要做
- tag = "h1"
%tag
干杯
我使用的最终版本是
-# 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 ]
是的,有可能。
尝试这个。
- tag = 'h1'
- haml_tag tag, "I'm h1."
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句