hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.47k stars 4.86k forks source link

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

Closed alonprince closed 10 years ago

alonprince commented 10 years ago

因为我工作中用的模板引擎是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>
Xuanwo commented 10 years ago

参见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.

alonprince commented 10 years ago

好的,谢谢了

alonprince commented 10 years ago

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

{% 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 /%}
tommy351 commented 10 years ago

Use {% raw %}{% endraw %}

alonprince commented 10 years ago

thanks

gshmu commented 10 years ago

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

alonprince commented 10 years ago

不好意思,忘了点了