主要成分:渲染jst.ejs文件中的动态内容 [英] Backbone: rendering dynamic content in jst.ejs files

查看:166
本文介绍了主要成分:渲染jst.ejs文件中的动态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和瑞恩·贝茨一起以下Rails的Backbone.js的教程。他用jst.eco模板。不过,我使用jst.ejs文件。

I'm following along with Ryan Bates backbone.js tutorial for Rails. He uses jst.eco templating. However, I'm using jst.ejs files.

他认为造成他想插入模板,即项放在这里一些内容

His view creates some content that he wants to insert into the template, namely "Entries go here"

$(this.el).html(this.template(entries: "Entries go here"));
 return this;

和它会被插入<%= @entries%GT; 模板

<h1>App Name</h1>

<%= @entries %>

我和index.jst.ejs文件,这样做的,它不工作。

I'm doing this with index.jst.ejs files and it's not working.

第一。有谁知道我应该使用模板来呈现动态内容是什么标签?

First. Does anyone know what tags I should be using in the template to render dynamic content?

第二,它仍然是正确的办条目:条目去这里模板内的()括号,如

Second, is it still correct to do entries: "Entries go here" inside of the template() parentheses, as in

$(this.el).html(this.template({entries: "Entries go here"}));

请注意,我没有使用的CoffeeScript

Note, I'm not using coffeescript

推荐答案

不需要@或本在模板中的项的前面。

don't need a @ or 'this' in front of 'entries' in the template.

查看/项/指数

 render: function(){

    $(this.el).html(this.template({

        entries: "Entries go here"

    }));
    return this;
  }

模板/项/ index.jst.ejs

Templates/entries/index.jst.ejs

<%= entries %>

这篇关于主要成分:渲染jst.ejs文件中的动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆