handlebars.js

Emberjs-1.0.0-rc.6 using enumerable to list events occurring on a particular date

夙愿已清 提交于 2019-12-04 06:22:08
问题 When I define a controller action to display dates occuring a particular date, it works correctly, but If I convert that controller action to a property it stops displaying the date occuring on a particular event. The jsfiddle App.EventsController = Em.ArrayController.extend({ todayEvent: function(date){ return this.get('content').filter(function(event) { return (moment(event.get('start')).unix() == moment(date).unix()); }); } }); I can fetch an instance of the controller: u = App.__container

How can we custom sort JavaScript object keys?

亡梦爱人 提交于 2019-12-04 05:51:55
问题 I am trying to custom sort a JavaScript object but not able to get how we can do this in a right way. Say I am having an object like var test = { 'yellow': [], 'green': [], 'red': [], 'blue': [] } And I have an array with values of : var arr = ['red', 'green', 'blue', 'yellow']; So after sorting, I want to output in the order which is specified in array like var test = { 'red': [], 'green': [], 'blue': [], 'yellow': [] } But for some reason, I am not able to achieve that. What am trying to do

How to access this json object from handlebarsjs

╄→尐↘猪︶ㄣ 提交于 2019-12-04 05:51:22
问题 How to access this json object from handlebarsjs [ { "id" : 9, "name" : "Name1", "address" : "address1", "city" : "city1", "state" : "KS", "zip" : "11111", "country" : "USA", "fax" : "111111", "phone" : "1111111", "website" : "", "account" : "11111", "contacts" : [] }, { "id" : 12, "name" : "Name2", "address" : "address2", "city" : "city2", "state" : "NJ", "zip" : "11111", "country" : "USA", "fax" : "", "phone" : "1111", "website" : "", "account" : "11111", "contacts" : [ { "firstName" :

set the first radio button is checked in handlebars template

眉间皱痕 提交于 2019-12-04 05:11:25
How can i get a easy and clear way that set the first radio button is checked in Handlebars template. tks template: <form> {{#each this}} <input value="{{value}}" /> {{/each}} </form> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ expect render: <form> <input value="val 1" checked /> <input value="val 2" /> <input value="val 3" /> </form> thanks all. {{#each}} in Handlebars doesn't give you access to the iteration number or anything like that so you can't do it without altering your template and data a little bit: <form> {{#each this}} <input type="radio" value="{{value}}" {{#if sel}}checked=

Bindings Computed Property in Ember TextField

我只是一个虾纸丫 提交于 2019-12-04 04:41:27
I'm trying to bind my data model to the text field in Ember.js. The model has a field that represents a currency value (e.g., $1,000.50). The user can then change this value. Ember receives the data as a Number (1000.50) -not currency formatted. I bind the view to a computed property that has the nice format. Here is my Handlebars template. {{input classNames="amount" valueBinding="p.amountFmt"}}</td> My model looks like: App.Product = Ember.Object.extend({ amount : 0.00, amountFmt: function () { //example. Do actual formatting with this.get('amount'); var formattedNum = '1,000.50'; return

VSCode : disable formatting of a specific file (or extension) [duplicate]

邮差的信 提交于 2019-12-04 03:55:20
This question already has an answer here: How to exclude files from “format on save” in VSCode? 2 answers Using Visual Studio Code, is it possible to disable the formatting of a specific file (or extension)? I try to use some Handlebars templates and I don't want VSCode to format them, at all. A simple example would be : {{test1}} {{test2}} When I save this file (I do have - and want - "editor.formatOnSave" set to true ), VsCode transforms the content to {{test1}} {{test2}} The only way I found for the file to stay untouched, is to name it " template.txt " instead of " template.hbs ". Any idea

Error: Missing Helper in Handlebars.js

≡放荡痞女 提交于 2019-12-04 03:32:23
I am using handlebars.js templates with node and express. I am making a numbered list using the {{@index}} template tag, however since index starts at 0 and I want to start from one, it seems I need to use a custom helper. I've seen plenty of posts regarding this and I've found the following code: Handlebars.registerHelper("inc", function(value, options) { return parseInt(value) + 1; }); {{#each score}} <li class="list-group-item"> <div id="place"> {{inc @index}} &nbsp </div> <div class="wordOrName">{{ player_name }}</div> <div class="number">{{ score }}</div></li> {{/each}} What I cannot seem

How does Ember.js reference Grunt.js precompiled Handlebars templates?

这一生的挚爱 提交于 2019-12-04 02:39:58
I've been exploring Ember.js, along with Grunt.js but I can't understand how Ember.js is able to find and use precompiled Handlebars templates. Right now my Gruntfile.js looks like this: module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), handlebars: { compile: { files: { "js/templates.js": "templates/*.hbs", } } } }); // Load the plugin that handles the handlebars compiling grunt.loadNpmTasks('grunt-contrib-handlebars'); // Default task(s). grunt.registerTask('default', ['handlebars']); }; And my app.js Ember views are

How to use Handlebars ternary helper?

对着背影说爱祢 提交于 2019-12-04 02:31:14
Following this answer , I wrote a helper like module.exports.register = function (Handlebars) { Handlebars.registerHelper('ternary', function(test, yes, no) { return test ? yes : no; }); }; I'm certain that the helper is loaded and being defined but can't figure out the syntax to use it. I tried using it like <div>{{ternary(true, 'yes', 'no')}}</div> but that gives an assemble build error Warning: Parse error on line 10: ...<div>{{ternary(true, 'yes', ----------^ Expecting 'ID', 'DATA', got 'INVALID' Use --force to continue. What is the proper syntax to use a helper like that? Handlebars

Handlebars.js disable escaping with noEscape option?

半城伤御伤魂 提交于 2019-12-04 01:52:11
I have all my content pre-escaped, so rather than using the triple stash everywhere i would like to globally disable handlebars escaping. A quick search showed a similar feature which I can see in my build of handlebars, however I don't know how to turn it on. The pull request is here: https://github.com/wycats/handlebars.js/pull/121 I've tried adding Handlebars.Compiler.options.noEscape = true in my code but it always comes back with options undefined. Even after defining the options its not picking it up. Does anyone know how I should be enabling this option in my script file? Thanks Try