hexo icon indicating copy to clipboard operation
hexo copied to clipboard

文章内容含有{{会报错,无法写handlebars的代码

Open alonprince opened this issue 12 years ago • 7 comments

因为我工作中用的模板引擎是handlebars,所以在写博文的时候,会出现大量的{{Variables}},我在代码块写入这些handlebar的变量时,就会一直报错,严重影响了我的写作体验,望早日解决,谢谢。 代码如下:

<head>
  <title>admin</title>
</head>
<body>
  {{> hello}}
</body>
<template name="hello">
  <h1>Hello World!</h1>
  {{> loginButtons}}
  {{greeting}}
  <input type="button" value="Click" />
</template>

alonprince avatar Oct 14 '14 06:10 alonprince

参见http://hexo.io/docs/troubleshooting.html

Hexo uses Swig to render posts. Contents wrapped with {{ }} or {% %} will be parsed and may cause problems. You can wrap sensitive contents with raw tag plugin.

Xuanwo avatar Oct 14 '14 06:10 Xuanwo

好的,谢谢了

alonprince avatar Oct 14 '14 06:10 alonprince

您好,我试了一下,发现还是报错,您看我写的对么?

{% rawblock %}
<head>
  <title>admin</title>
</head>
<body>
  {{> hello}}
</body>
<template name="hello">
  <h1>Hello World!</h1>
  {{greeting}}
  {{> loginButtons}}
  <input type="button" value="Click" />
</template>
{% endrawblock /%}

alonprince avatar Oct 14 '14 06:10 alonprince

Use {% raw %}{% endraw %}

tommy351 avatar Oct 14 '14 06:10 tommy351

thanks

alonprince avatar Oct 14 '14 06:10 alonprince

Mark {% raw %}{% endraw %} @alonprince 自觉Close issue

gshmu avatar Oct 22 '14 03:10 gshmu

不好意思,忘了点了

alonprince avatar Oct 22 '14 03:10 alonprince