【发布时间】:2015-06-04 10:38:58
【问题描述】:
是否可以在包含中使用前面的内容。我有一个名为 image.html 的包含,看起来像这样。
image.html
{% if layout == 'page' %}
<img src="{{ site.url }}/public/img/{{ include.url }}" class="page">
{% else %}
<img src="{{ site.url }}/public/img/{{ include.url }}">
{% endif %}
还有一个看起来像这样的about.md 文件:
about.md
---
layout: page
---
{% include image.html url="img.jpg" %}
但由于某种原因,它无法识别 if layout 语句。知道如何让它工作吗?
感谢任何帮助。提前致谢!
更新
完整问题如下:
如果页面中包含image.html 包含,则包含需要具有完全不同的布局,包含两个封装元素(container 和sm-col-12)。希望下面的内容比我原来的问题更有意义。
image.html
{% if include.size == 'full' and include.type != 'gif' %}
<section class="image full-width">
<img src="{{ site.url }}/public/img/{{ include.name }}.{{ include.type }}">
</section>
{% elsif layout == 'page' and include.type != 'gif' %}
<div class="container">
<div class="sm-col-12">
<section class="image">
<img src="{{ site.url }}/public/img/{{ include.name }}.{{ include.type }}">
</section>
</div>
</div>
{% elsif include.type != 'gif' %}
...
{% else %}
...
{% endif %}
about.md
---
layout: page
---
{% include image.html name="zifferblatt" type="jpg" %}
【问题讨论】:
标签: if-statement jekyll liquid