整合iCanHaz和木偶

编程入门 行业动态 更新时间:2024-10-23 21:38:20
本文介绍了整合iCanHaz和木偶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我ICanHaz的忠实粉丝,我试图直接intregrate到一个新的应用程序木偶我建立。然而,去了这个帖子,我写了这个到达到渲染方法,并改变它在木偶:

I'm a big fan of ICanHaz, and I'm trying to directly intregrate it into a new Marionette application I'm building. However, going off this post, I have written this that reaches into the render method and changes it in Marionette:

// Set up Initalizer APP.addInitializer(function() { //Reach into Marionette and switch out templating system to ICH Backbone.Marionette.Renderer.render = function(template, data){ return ich[template](data); } //Create Router new APP.Routers.GlobalRouter(); //Start Backbone History Backbone.history.start(); });

如果我走通过这个功能,所有的数据似乎做工精细。但是,投入使用,并试图用它的布局和项目视图时,没有被追加或插入。这是从我GlobalRouter:

If I walk through this function, all the data seems to work fine. However, when put into use and trying to use it for layouts and Item Views, nothing gets appended or inserted. This is from my GlobalRouter:

//Grab the main Layout var layout = new APP.Views.LayoutView(); //Render that layout layout.render(); //Make the model var userModel = new APP.Models.UserModel({ "user_name" : "nweingartner@awesome", "tenant" : "Ginger Ale is Great" }); //Make the Header Region var headerRegion = new APP.Views.HeaderView({model: userModel}); layout.header.show(headerRegion);

这一切都发生在一个索引时被击中被调用的方法。有没有JS错误,所以我没有去。然而,它在渲染功能,我将数据追加到体内,它会增加(但是毁了我的布局和区域结构)。

This all happens in a method that gets called when index is hit. There are no JS errors so I have nothing to go on. However, it in the render function I append the data to the body, it will add (however ruining my layout and region structure).

我储存我的模板的index.html。

I am storing my templates in index.html.

任何人都可以在这方面帮助?

Can anyone help with this?

推荐答案

好吧,我找不到一个简单的方法来做到这一点使用ICH。然而,由于其他SO,我发现非常类似的功能,可以只用胡子找到。

Okay, I couldn't find an easy way to do this using ICH. However, due to another SO I found, very similar functionality can be found just using Mustache.

使用这个code:

Backbone.Marionette.TemplateCache.prototypepileTemplate = function(rawTemplate) { return Mustachepile(rawTemplate); }

用于更改渲染器,因此您可以从index.html的使用木偶的模板调用胡子拉模板。胡须模板看起来是这样的:

Lets you change the renderer so you can pull mustache templates from index.html using Marionette's template call. A mustache template looks like this:

<script id="headerTemplate" type="text/template"> <p>{{user_name}}</p> <p>{{tenant}}</p> </script>

不同的是,该类型是文本/模板,而不是文本/ html。否则,它的作用非常相似。

The difference is that the type is 'text/template' as opposed to 'text/html'. Otherwise it acts very similar.

希望这可以帮助其他人。

Hope this helps someone else.

更多推荐

整合iCanHaz和木偶

本文发布于:2023-11-06 21:38:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564739.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:木偶   iCanHaz

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!