【问题标题】:include file without swig parsing it as a template包含文件而无需 swig 将其解析为模板
【发布时间】:2015-03-11 15:20:41
【问题描述】:

我想在 swig 模板中包含一个文件,而不需要 swig 将其解析为 swig 模板。类似于文件的原始标签。

使用swig-highlight 我想让它工作。

{% highlight 'html' %}
    {% import 'some-template-file.html' %}
{% endhighlight %}

问题是“some-template-file.html”是一个 Jekyll 模板并在 swig 中引发错误。

【问题讨论】:

    标签: swig-template


    【解决方案1】:

    您可以尝试使用raw tag。这忽略了任何内部 swig 语法,并且应该也忽略任何其他语法。

    // inside (e.g.) index.html
    {% import 'some-template-file.html' %}`
    
    // inside some-template-file.html
    {% raw %} {{ testVar }} {% endraw %}
    // results in "{{ testVar }}"
    

    【讨论】:

      猜你喜欢
      • 2015-07-25
      • 2018-02-08
      • 2013-06-16
      • 1970-01-01
      • 2018-08-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-04
      • 2013-12-16
      相关资源
      最近更新 更多