handlebars.js

Handlebars template's filename extension

霸气de小男生 提交于 2019-12-06 17:00:51
问题 I changed my handlebar template's extension and referred to the same in the function which called handlebarjs' compile function. It worked perfectly fine with no issues. But I'm curious to know if anyone else tried that? Please let me know if you think this could cause problems down the road for any reason. For some reason I feel that the very extension .handlebars is a bit long. I prefer to keep it to a max of 4 chars ... something like .txt or .html. Please let me know if you see any issues

Mixing handlebars.js and CSS - Random background image?

纵然是瞬间 提交于 2019-12-06 16:05:38
I would like to set a randomly generated background image. I am using Meteor and am calling Flickr API to provide a random image URL which I would like to set as my background image. From what I've read, it seems that CSS is now the recommended way to set a background image. Is there a way to inject the dynamically generated url into the CSS? I can't seem to find examples showing mixing of Handlebars.js and CSS - is this possible? Or should I be avoiding CSS and setting the background image using the traditional HTML way? I've been trying two different strategies: 1) To create the CSS

Emberjs: Cannot createRecord with Ember Data 1.0.0 beta

删除回忆录丶 提交于 2019-12-06 14:27:58
I have an app that keeps multiple task lists. Each task list has multiple tasks. Each task has multiple comments. After updating to the new Ember Data, I had to scrap my record creation code. Currently I have this, which doesn't work. Though it doesn't throw any errors, my model does not seem to be updating. App.TaskController = Ember.ArrayController.extend({ needs : ['list'], isEditing : false, actions : { addTask : function(){ var foo = this.store.createRecord('task', { description : '', list : this.get('content.id'), comments : [] }); foo.save(); console.log('Task Created!'); }, edit :

Lookup helper in handlebars

倾然丶 夕夏残阳落幕 提交于 2019-12-06 13:26:53
I have a 'countries' object which I pass as part of the Handlebars context: { 'hk': {'name': 'Hong Kong', 'someotherprop': 'someothervalue'}, 'us': {'name': 'United States', 'someotherprop': 'yetanothervalue'}, ... } I want to use the lookup Handlebar helper to find from the countrycode 'hk' the name 'Hong Kong'. I can get the following object {'name': 'Hong Kong', 'someotherprop': 'someothervalue'} using the following Handlebars directive {{lookup ../countries countrycode}} but how do I now extract the name property from this object? Apparently one can chain lookup calls using the

How to integrate Handlebars template to Marionette View?

旧时模样 提交于 2019-12-06 12:51:18
问题 In my app, I am using the handlebars template plugin, I am little bit confused here, how can i integrate handlebars template to marionette Item View which is using separate template? here is my code : define([ 'jquery', 'underscore', 'backbone', 'marionette', 'hbs!scripts/templates/login/loginTemp'], // this is my handlebars template. function ($,_,Backbone,Marionette,loginTemplate) { "use strict"; socialApp = window.socialApp || {}; socialApp.loginView = Backbone.Marionette.ItemView.extend({

Binding child views and collections within an outlet in emberjs

旧时模样 提交于 2019-12-06 09:38:38
I'm trying to render a view Team inside of an {{outlet}} . This Team view is comprised of a simple Person view (the team leader), and a collection of Person views (team members). The outlet is set up by calling connectOutlet() on the ApplicationController. Although the Person child views are rendered in the markup as expected, all the values of name are missing. It sure seems like my bindings and/or controller are not set up properly. What am I missing? Code and demo: http://jsfiddle.net/aek38/fkKFJ/ The relevant handlebar templates are: <script type="text/x-handlebars" data-template-name="app

How do I resolve type error this.merge is not a function trying to run Mozart app?

爷,独闯天下 提交于 2019-12-06 09:32:31
I'm trying to start a Mozart app, but nothing is rendering and I'm getting the error... TypeError: this.merge is not a function helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; Nothing obviously related has changed - ie. haven't changed the templates etc so it's hard to see what's wrong. Have tried an npm install and re-run to no avail. Anyone hit this problem? It sounds like the version of Handlebars used to precompile your templates is different to the version actually running on your page. Specifically, this.merge was added in Handlebars 1.0.0 final, so if your page is

How to pass Express response object to frontend JS object

你。 提交于 2019-12-06 09:32:13
问题 My controller is sending lat/lng data to my Handlebars view via res.render. res.render('coords', viewModel); 'viewModel' contains an array of objects, with each object containing a name of a location, lat, and lng. I want to take this information and plot markers on a Google map in my view. When I attempt to inject the data by way of Handlebars into an inline JS variable... <script> var viewMarkers = {{viewModel}}; console.log(viewMarkers); </script> I get this in my console... <script> var

Handlebars.registerHelper - Way to get content of Block?

 ̄綄美尐妖づ 提交于 2019-12-06 08:32:51
is there a way in registerHelper to get the content of a block? Lets assume we have the following template: {{#myif test}}thats the content i want to have{{/myif}} And the following registerHelper Code: Ember.Handlebars.registerBoundHelper('myif', function(test) { // do something return <content of handlebars block>; }); Many thanks! Handlebars provides the nested block to the helper as options.fn , where options is the last argument of your helper. You can invoke this block with a context object which is where that block will pick up values from. To pass the context of the helper itself you

Insert partial/component at dynamic location

依然范特西╮ 提交于 2019-12-06 08:11:07
I created a blog where I've got a {{downloads}} component showing the downloads which belong to a post. Currently I render the downloads below {{{post.content}}} . I'd like to have a special string withing post.content like [postDownloads] and render {{downloads}} there. Is this somehow possible or are there other approaches to solve this problem? I put together an easy example illustrating one of the use-cases I'm trying to solve: http://emberjs.jsbin.com/raresalihu/3/edit App = Ember.Application.create(); App.IndexRoute = Ember.Route.extend({ model: function() { return { title: "cool post