本文介绍了如何逃脱{{在Octopress的降价促销中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Octopress撰写博客,并且想要发布以下代码段(这是Mustache JS语法):

I'm using Octopress to blog, and I want to post the following code snippet (it's Mustache JS syntax):

```
<ul id="beers-list">
    {{#beers}}
        <li>{{name}} - {{color}} - {{alcohol}}%</li>
    {{/beers}}
</ul>
```

不幸的是,渲染后,所有{{...}}都消失了,我在网站上看到了以下内容:

Unfortunately, when rendered, all {{...}} disappear, and I see the following on my website:

<ul id="beers-list">

        <li> -  - %</li>

</ul>

我无法转义{{(即使使用\{{{\{或类似的东西.是否有办法转义这些字符?

I was not able to escape the {{ (even with \{{, {\{ or something like that. Is there a way to escape these characters?

谢谢.

我不确定SO是否是此问题的最佳选择

推荐答案

感谢另一个非常相似的问题(和答案),此处,我找到了解决方案.我必须用{% raw %}{% endraw %}包装代码块:

Thanks to another quite similar question (and answer) here, I've found the solution. I have to wrap my code block with {% raw %} and {% endraw %}:

{% raw %}
```
<ul id="beers-list">
    {{#beers}}
        <li>{{name}} - {{color}} - {{alcohol}}%</li>
    {{/beers}}
</ul>
```
{% endraw %}

这篇关于如何逃脱{{在Octopress的降价促销中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 02:37