handlebars.js

Handlebar.js Memory leak in IE9

懵懂的女人 提交于 2019-12-11 11:43:17
问题 I am wondering if any one has experienced memory leak from using Handlebar.js compile function. I am currently working on a single page app which polls data periodically from server via Ajax call. Every time when I get new data, I re-render the view. (I am using Backbone.js in conjunction with handlbar.js. I understand that I need to manually free view objects when I close the view or switch to other view, I think that is not the case here. At least, I think it is not. Regarding to this topic

How to compare values in each?

自闭症网瘾萝莉.ら 提交于 2019-12-11 11:39:53
问题 I found compare helper for handlebars https://gist.github.com/doginthehat/1890659. And I try to use it like that: {{#each item in model.records}} <div> {{#compare model.currentUser.id item.poster_id}} <div class="author current">{{model.currentUser.name}}</div> {{else}} <div class="author remote">{{model.remoteUser.name}}</div> {{/compare}} <div class="td message-text"> {{item.poster_id}}{{item.text}} </div> </div> {{/each}} But it doesn't work. Because helper doesn't recognize second

Could not find property 'link_to' on object (generated application controller).

假装没事ソ 提交于 2019-12-11 11:38:39
问题 I have a simple index.html with an application template that includes: <script type="text/x-handlebars"> <nav> <ul> <li> <h1>{{#link_to 'index'}}Bookmarker{{/link_to}}</h1> </li> <li> {{#link_to 'bookmarks'}}Bookmarks{{/link_to}} </li> </ul> </nav> {{outlet}} </script> Otherwise my ember code is: App = Ember.Application.create(); App.Store = DS.LSAdapter; App.Router.map(function(){ this.resource('bookmarks'); }); when running this in the browser I get: DEBUG: -------------------------------

How to create element from HTML in Prototype?

一笑奈何 提交于 2019-12-11 11:13:50
问题 Is there a way to create element from HTML in Prototype that's an analog to jQuery's $('<div>Foo</div>') ? Basically I create HTML chunk from a Handlebars template and want to insert into DOM but don't want to wrap it in some other element. 回答1: I added this function as a 'static method' to Mustache for one of my recent projects to solve the same problem. I don't believe there is anything built-in to Prototype to solve this. I used hidden textareas to hold my template code, hence the $F()

Issue rendering collection data in handlebars template

人走茶凉 提交于 2019-12-11 11:08:38
问题 I want to render collection in handlebars precompiled templates, this.courses.fetch() is working handlebars view is rendering correctly...(only each loop not rendering collection data) here is my code... router.js App.Router = Backbone.Router.extend({ routes: { 'master/courses' : 'courses' }, initialize: function(){ this.courses = new App.Collections.Courses(); this.list = new App.Views.List( {collection: this.courses} ); }, courses: function() { $('#page').html(this.list.render().el); } });

Passing content to nested partials in assemble

走远了吗. 提交于 2019-12-11 10:28:01
问题 I'm using assemble for prototyping a new site. I would like to modularize my code quite drastically, much like Brad Frost is evangelizing with his pattern lab. EXAMPLE Basically I would like to have a title partial ("atom" in pattern-lab speak) which is used inside a hero partial ("molecule"): title.hbs <h1 class="{{class}}">{{text}}</h1> hero.hbs <section class="hero-unit"> {{!-- image and stuff --}} <header class="hero-description"> {{> title }} {{> subTitle }} </header> </section> The hero

How to precompile gulp-handlebars helpers?

流过昼夜 提交于 2019-12-11 10:26:43
问题 I am precompiling my templates into JS using gulp-handlebars but I am having trouble getting custom handlebars helpers to also precompile. Does anyone know if there is any support/way to precompile custom helper methods? 回答1: I noticed that gulp-handlebars can use a specific handlebars library, essentially overriding its default. So, by just creating my own module and registering some helpers, and feeding that into the handlebars call, things are working locally. // helpers.js var handlebars

How to represent Array of integers in handlebar.js

会有一股神秘感。 提交于 2019-12-11 10:17:14
问题 I have a json object "FoundAt" : [1, 3] How do I represent the values in the array using handlebar.js? 回答1: If you are referring to iterating the array you can do so using {{each}} block, with reference to the above defined array use the following: {{#each jsonObjectName.FoundAt}} {{this}} {{/each}} OR {{#each number in jsonObjectName.FoundAt}} {{number}} {{/each}} Look for Simple Iterators in the official documentation 来源: https://stackoverflow.com/questions/13622660/how-to-represent-array

Handlebars not loading after Require.js optimization with grunt-requirejs

↘锁芯ラ 提交于 2019-12-11 10:08:58
问题 I'm using the Yeoman Backbone generator for my app. I wanted to use Handlebars for templates. When I include a shim, it works great in development with grunt serve . // main.js require.config({ shim: { bootstrap: { deps: ['jquery'], exports: 'jquery' }, handlebars: { exports: 'Handlebars' } }, paths: { jquery: '../bower_components/jquery/dist/jquery', backbone: '../bower_components/backbone/backbone', underscore: '../bower_components/underscore/underscore', bootstrap: '../bower_components

Chrome extension - inject template through content_scripts

若如初见. 提交于 2019-12-11 09:55:39
问题 I'm trying to inject a handlebars template in a page using content_scripts from the Chrome extension, using the following code in the page called from content_scripts : var xhr = new XMLHttpRequest(); xhr.open('GET', chrome.extension.getURL('app/templates/tpl.handlebars'), true); xhr.onreadystatechange = function() { if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { var tplScript = document.createElement('script'); tplScript.text = xhr.responseText; tplScript.id = "mytpl";