如何在laravel 4.2中使用handlebar js转义html
How to escaping html in laravel 4.2 with handlebar js?
这是我在laravel blade中的html代码。
<script id="expressions-template" type="text/x-handlebars-template">
@{{description.escaped}}
@{{example}}
@{{description.unescaped}}
@{{{example}}}
</script>
<div class="content-placeholder"></div>
这是我的js脚本编译模板与数据
$(function () {
// Grab the template script
var theTemplateScript = $("#expressions-template").html();
// Compile the template
var theTemplate = Handlebars.compile(theTemplateScript);
// Define our data object
var context={
"description": {
"escaped": "Using {{}} brackets will result in escaped HTML:",
"unescaped": "Using {{{}}} will leave the context as it is:"
},
"example": "<button> Hello </button>"
};
// Pass our data to the template
var theCompiledHtml = theTemplate(context);
// Add the compiled html to the page
$('.content-placeholder').html(theCompiledHtml);
});
laravel (4.2) blade不转义HTML标签,它只是将HTML标签作为文本打印
Blade::setEscapedContentTags('[[', ']]');
Blade::setContentTags('[[[', ']]]');
为一个视图使用不同的标签,你可以在闭包或控制器动作中设置这些标签,它们将生成视图。
车把模板使用花括号
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 使用agility.js进行页面布局和合成
- 使用Clipboard.js复制span文本
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 强制模板刷新ember.js
- 如何编写HTML输入的JS内联
- Angular JS IE9 Hashbang url rewriting
- 使用JS将数组转换为json对象
- 在单个文件中需要js和多个已编译的Handlebar.js模板
- 将值添加到Handlebar.js@index
- Handlebar.js模板,使用Undercore.js-Zendesk应用程序进行动态表单输入
- HandleBar js 和 Mustache js 之间的关系
- handlebar.js和handlebar.runtime.js有什么区别
- Handlebar.js与{{this}}的条件比较
- 是否有一种方法来迭代和显示json的键值对列表使用Handlebar.js
- 如何在laravel 4.2中使用handlebar js转义html
- 如何使用Handlebar.js向表中添加行
- Handlebar.js and Safari
- 使用handlebar.js进行循环
- Handlebar.js没有刷新我的模板