简体   繁体   English

流星模板:解析html内容

[英]meteor template: parse html content

I saved some HTML-content in my collection. 我在集合中保存了一些HTML内容。 By using IronRouter data() will be used to set the cursor/array. 通过使用IronRouter, data()将用于设置光标/数组。 In this example I just show an example array. 在此示例中,我仅显示示例数组。

Now the HTML-content isn't shown correctly, as it doesn't get parsed. 现在,HTML内容无法正确显示,因为无法解析。 The user would see the HTML-tags. 用户将看到HTML标签。 What do I have to do to get the content displayed correctly? 我该怎么做才能正确显示内容?

IronRouter 铁路由器

Router.route('/article/:_id', {
    name: 'article',
    data: function () {
        var articles = [{ title: 'title', content: '<strong>content</strong>'}];
        return { articles: articles };
    }
});

template 模板

<template name="article">
    {{#each articles}}
        <h1>{{title}}</h1>
        <section>{{content}}</section>
    {{/each}}
</template>

Use Handlebars triple-stash : 使用车把三重存储

<template name="article">
  {{#each articles}}
    <h1>{{title}}</h1>
    <section>{{{description}}}</section>
  {{/each}}
</template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM