handlebars.js

Accessing an instance of a controller or a view in ember

旧街凉风 提交于 2019-12-03 06:13:50
问题 My understanding is that when I run App.CheeseController = Ember.Controller.extend({ type:"brie"}); A class CheeseController is created and that when I activate the Cheese route an instance of that class is made which is what I actually touch when talking to the controller in my handlebars template. Is it possible to directly access that instantiated object from within the javascript console (or from within my program)? More generally, where do the objects that Ember automatically makes live?

How to use multiple parameters in a handlebar helper with meteor?

孤街醉人 提交于 2019-12-03 06:13:24
问题 I am trying to create a custom helper using Meteor. Following to the doc here: https://github.com/meteor/meteor/wiki/Handlebars I have tried to define my helper as follows: Template.myTemplate.testHelper = function(foo, bar, options) { console.log(foo); console.log(bar); } My template looks like: <template name="myTemplate"> {{#testHelper "value1" "value2"}} {{/testHelper}} </template> Looking at my console output, I expected to see 2 lines of output: value1 value2 However my console looks

Using @index in meteor #each iterator doesn't work [duplicate]

半腔热情 提交于 2019-12-03 06:07:23
This question already has answers here : How can I get the index of an array in a Meteor template each loop? (6 answers) why doesn't this work in meteor? https://github.com/wycats/handlebars.js/issues/250 It's not yet implemented in meteor's version of handlebars; there's a subtlety about the reactivity of @index rendering properly. You can read more about it here: https://github.com/meteor/meteor/issues/489#issuecomment-11270564 This is definitely a frustration for me as well. In the meantime I made a handlebars helper to parse anything into named 'key' and 'value' objects: Handlebars

Easy way to precompile Emberjs Handlebar templates with nodejs?

浪尽此生 提交于 2019-12-03 05:59:25
问题 I'm enjoying emberjs a lot and would like to take the next step in a couple of my small, mobile apps and precompile my Ember/Handlebars templates as part of my build process. I'd prefer to stay away from messing with Ruby and would like to use node.js as I'm more comfortable with using it. I believe what I want to use is Ember.Handlebars.precompile, but unfortunately I'm unable to load the canonical ember.js file in a node environment. Example of a naive attempt from the node repl: > var e =

Handlebars nested 'each' syntax - not iterating over each element

為{幸葍}努か 提交于 2019-12-03 05:59:00
问题 I am brand new at this Javascript/JSON/Handlebars thing, and I am having trouble getting a JSON object, with two nested levels, to work in a Handlebars template. I have validated the JSON object with JSONLint, so it is valid JSON code, but I don't know if I have the correct JSON format to make the template work correctly. :) (I am building the JSON manually in another system.) Or perhaps it is the syntax of the template that I have incorrect. That's what I hope to find out... The short

How to decode HTML entity with Handlebars

喜夏-厌秋 提交于 2019-12-03 05:46:13
问题 I'm using the Handlebars templating engine on the app I'm building to render the data I get from the server. I know that it escapes HTML values by default and that you have to use the triple brackets {{{text}}} in order for text: <p>Example</p> to be rendered as an HTML element. The problem is, what do I do if the data I receive, including the HTML tags, is already escaped? So, if I receive data like: text: <p>Example</p> How do I force handlebars to translate it and render it as normal HTML?

backbone.marionette + i18n + handlebars

佐手、 提交于 2019-12-03 05:25:52
问题 Can some one post an example of combining these libraries together? including the handler for the i18n and marionette. Thanks 回答1: point backbone.marionette templates to compile hendlebars. this can be done on your main.js: Backbone.Marionette.TemplateCache.prototype.compileTemplate = function(rawTemplate) { return Handlebars.compile(rawTemplate); }; configure your app to use handlebars and i18n: this can be done on your config.js: require.config({ // Initialize the application with the main

app.set and app.engine in Express

匆匆过客 提交于 2019-12-03 05:13:47
问题 I am following a Node.js tutorial. Two lines for which I am not sure are: app.set('view engine', 'html'); app.engine('html', hbs.__express); I checked the documentation for app.set and it only tells me: Assigns setting name to value. But my question is what's the relevance of using this. I googled it and wherever app.engine is used app.set is called before. Let me know the significance of using app.set before the app.engine . EDIT I found the following line, but I am still unclear as I am

Handlebars.js: Use a partial like it was a normal, full template

扶醉桌前 提交于 2019-12-03 04:55:16
I have a template that I want to use both as a partial, and by itself from javascript. If your templates are precompiled, you can access your partials via Handlebars.partials['partial-name']() as well as call them from a template via the {{> partial}} helper. This is nice because you can then write a utility function for rendering a template whether it be a full blown template or partial. ex: function elementFromTemplate(template, context) { context = context || {}; var temp = document.createElement('div'); temp.innerHTML = templates[template] ? templates[template](context) : Handlebars

How to pass parameters with the action Helper of Ember.js?

那年仲夏 提交于 2019-12-03 04:52:58
I have a list of items: <ul> {{#each applications}} <li> <a {{bindAttr href="url"}} {{action "appClicked" on="click"}}> {{name}} </a> </li> {{/each}} </ul> On click it calls the method appClicked of the view, that this template belongs to. I want to pass some information (for example, the name of the application) to the method appClicked . Something like, {{action "appClicked(name)" on="click"}} . Is it possible, and how? Roy Daniels I was thinking something more along the lines of this since you'll have access to a bunch more through an actual view. But Zack, if you could explain a bit more