2016-08-02 47 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