Integrating iCanHaz and Marionette

前端 未结 1 1081
暖寄归人
暖寄归人 2020-12-20 09:00

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

相关标签:
1条回答
  • 2020-12-20 09:59

    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.

    Using this code:

     Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) {
        return Mustache.compile(rawTemplate);
     }
    

    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>
    

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

    Hope this helps someone else.

    0 讨论(0)
提交回复
热议问题