How to escape {{ in markdown on Octopress?

北慕城南 提交于 2019-12-22 05:43:27

问题


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?

Thanks.

I'm not sure if SO is the better site for this question


回答1:


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 %}


来源:https://stackoverflow.com/questions/15786144/how-to-escape-in-markdown-on-octopress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!