是否可以在单个include中包含多个参数?
单
{%include card.html class = include.class1%}
多个??
{%include card.html class = include.class1&& include.class2%}
或者我必须做class1 = include.class1 class2 = include.class2?
答案 0 :(得分:4)
可以使用空格param1=value1 param2=value2
分隔多个include参数,例如:
{% include image.html url="http://jekyllrb.com"
max-width="200px" file="logo.png" alt="Jekyll logo"
caption="This is the Jekyll logo." %}
然后你可以在里面访问前面的前缀<{1}},例如:
include.
答案 1 :(得分:0)
正如@marcanuy所说,
一种方法是使用捕获功能将多个值包含在一个参数中。
{%capture classes%} {{include.class1}} {{include.class2}} {%endcapture%}
{%include card.html class = classes%}
答案 2 :(得分:0)
这是我的用例-
一个包含html的单选按钮集,例如:
<label>{{include.label}}</label>
{% for option in include.options %}
<input type="radio" name="{{include.label}}" id="{{include.option}}" value="{{include.option}}" checked="checked"/><label for=" {{include.option}}">{{include.option}}</label>
{% endfor %}
您这样称呼:
{% include radiobuttons.html label="favorite color" options="green", "blue", "orange", "red" %}