【发布时间】:2016-11-30 12:22:56
【问题描述】:
我在我的项目中使用了haml。通过将以下代码行添加到 example.js.haml 将返回 <h1>hello</h1> 而不是 hello
:plain
document.getElementById('light').append("#{escape_javascript(raw '<h1>hello</h1>')}");
需要关于如何修改 example.js.haml 以便只返回没有 html 标签的 hello 的建议
【问题讨论】:
-
试试,
document.getElementById('light').append("#{escape_javascript('<h1>hello</h1>').html_safe}"); -
不,它不起作用:(
-
不是
{escape_javascript('<h1>hello</h1>').html_safe},如果有的话,那么{escape_javascript('<h1>hello</h1>'.html_safe)}。但我不确定这是否也有效 -
或者你的意思是真的打印
...?
-
我都试过了。它返回带有标题标签的 hello
标签: javascript ruby-on-rails haml