Reputation: 489
Is it possible to include multiple parameters in single include?
Single:
{% include card.html class=include.class1 %}
Multiple??
{% include card.html class=include.class1 && include.class2 %}
Or do I have to do class1=include.class1 class2=include.class2?
Upvotes: 3
Views: 1201
Reputation: 11
Here's my use case for this-
an include that has html for a radiobutton set, like so:
<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 %}
that you call like this:
{% include radiobuttons.html label="favorite color" options="green", "blue", "orange", "red" %}
Upvotes: 1
Reputation: 489
As stated by @marcanuy,
One way is to use the capture function to include multiple values into a single parameter.
{% capture classes %} {{include.class1}} {{include.class2}} {% endcapture %}
{% include card.html class=classes %}
Upvotes: 0
Reputation: 23952
Multiple include parameters can be passed separated with a space param1=value1 param2=value2
,e.g.:
{% include image.html url="http://jekyllrb.com"
max-width="200px" file="logo.png" alt="Jekyll logo"
caption="This is the Jekyll logo." %}
Then you can access them inside the include file prefixing it with include.
, for example:
{{include.file}} {{include.caption}}
Upvotes: 6