2016-08-02 49 views
1

我想用n2o和rebar3编写web。 但我得到的页面错了,代码在这里。erlang n2o渲染得到< span id =“

index.erl

​​

prod.dtl

<html > 
<head> 
    <title>{{title}}</title> 
</head> 
<body> 
      {{body}} 
</body> 
</html> 

我得到的结果是:

<html > 
<head> 
    <title></title> 
</head> 
<body> 
      &lt;span id=&quot;display&quot;&gt;&lt;/span&gt;&lt;br/&gt;&lt;span&gt;Login: &lt;/span&gt;&lt;input id=&quot;user&quot; type=&quot;text&quot; autofocus=&quot;true&quot;/&gt;&lt;br/&gt;&lt;span&gt;Join/Create Feed: &lt;/span&gt;&lt;input id=&quot;pass&quot; type=&quot;text&quot;/&gt;&lt;button id=&quot;loginButton&quot; type=&quot;button&quot;&gt;Login&lt;/button&gt; 
</body> 
</html> 

我怎样才能得到 '<' 而不是 '& LT'

+1

是否将'{{body}}'更改为'{{body |安全}}在'prod.etl'中工作? – Dogbert

+0

您正在使用哪种版本的DTL? N2O支持到0.8。更新的版本由你决定。 – 5HT

+0

@Dogbert这是工作....谢谢 – hstcscolor

回答

0

erlydtl启用自动转义{{}}中的值this commit(也参见#80#120)。如果您使用的版本包含此提交(从页面看起来像0.9.0或更高版本),则必须手动将该值标记为安全。

相反的:

{{ body }} 

做:

{{ body | safe }} 

注意:您应该知道的标记不可信的字符串作为安全风险:https://en.wikipedia.org/wiki/Cross-site_scripting