是否可以{% include file.html %}不渲染其中的标签?
我试过{% include file.html | escape_once %}这给出了一个错误
运行它 {% raw %} {% include file.html %} {% endraw %}
给出{% include file.html %}(不足为奇)。
我正在寻找类似的东西 {% include file.html | no_render %}
我不能把原始标签放在里面的原因file.html是我试图将它作为模板重用(这有点像黑客)。
这对于试图自我描述的页面也有好处。IEThis useful thing works like this: {% include useful_snippet.html | no_render %}
有用的_snippet.html
{% raw %}
{% comment %}Alot of liquid code{% endcomment %}
{% assign toto = "Welcome to the hack !" %}
{% assign string = "a,b,c,d" %}
{% assign array = string | split:"," %}
{% for item in array %}
{{ item }}
{% endfor %}
{% endraw %}
Run Code Online (Sandbox Code Playgroud)
<pre><code>{% include useful_snippet.html %}</code></pre>
Run Code Online (Sandbox Code Playgroud)
{% highlight liquid %}{% include useful_snippet.html %}{% endhighlight %}
Run Code Online (Sandbox Code Playgroud)
编辑:在仅限 Jekyll 的进程中,Liquid 被渲染一次。因此,没有办法让一个模板同时渲染 Liquid 和渲染原始 Liquid 代码。
| 归档时间: |
|
| 查看次数: |
1179 次 |
| 最近记录: |