handlebars.js

How to set itemController in each as (ember 1.11 beta3)?

﹥>﹥吖頭↗ 提交于 2019-12-05 10:34:00
I want to try use: {{#each content as |product index|}} {{index}} {{/each}} But my app has the itemContoller, like this: {{#each product in content itemController='product'}} If I set this: {{#each content as |product index| itemController='product'}} It doesn't work! I found all of the ember guides and did not find the answer. Any help please. Controllers ( Object , Array and itemController ) are going away. The new way to do things is by using a component. So, instead of your item controller, you would define a component: App.MyProductComponent = Ember.Component.extend({ myIndex: function(){

boolean logic within a handlebars template

一笑奈何 提交于 2019-12-05 10:27:59
Is it possible to perform boolean logic within a handlebars conditional? Right now I spoof this behavior with a controller function, so I end up with the controller App.ApplicationController = Ember.Controller.extend({ bool1: true, bool2: true, both: function(){ return this.bool1 && this.bool2; }.property('content.both'), }); Which allows me to use a handlebars template of <script type="text/x-handlebars"> {{#if both}} <p> both were true </p> {{/if}} </script> and that works fine, but raises some problems. First off, it obscures what's happening (particularly if good function names aren't used

Handlebars.js - Access object value with a variable key

∥☆過路亽.° 提交于 2019-12-05 10:07:27
问题 Looking for a way to access to achieve this: {{#each someArray}} {{../otherObject.[this]}} {{/each}} How do I evaluate the value of this and then reference it as a key to my object otherObject ? 回答1: With lookup: http://handlebarsjs.com/builtin_helpers.html#lookup {{#each someArray}} {{lookup ../otherObject this}} {{/each}} 回答2: One possible solution with a helper: /* {{#each someArrayOfKeys}} {{#withItem ../otherObject key=this}} {{this}} {{/withItem}} {{/each}} */ Handlebars.registerHelper(

Handlebars error: Could not find property 'query-params' although Feature activated

痴心易碎 提交于 2019-12-05 06:54:59
I am trying to use query-params in my route / controller but the handlebars helper is causing this error: Uncaught Error: <(subclass of Ember._MetamorphView):ember689> Handlebars error: Could not find property 'query-params' on object . This error is caused by this link to helper: {{#link-to 'betround.stats' (query-params game=id) }} <li {{bind-attr class="isPast:small"}}> {{team1}} {{scoreT1}} : {{scoreT2}} {{team2}} (gameid: {{id}})</li> {{/link-to }} I have already upgraded Ember and Handlebars DEBUG: Ember : 1.4.0-beta.4 DEBUG: Ember Data : 1.0.0-beta.4 DEBUG: Handlebars : 1.3.0 DEBUG:

Using HTML anchors in Ember.js

折月煮酒 提交于 2019-12-05 06:30:53
In my Ember application, how can I jump to an HTML anchor inside one of my Handlebars templates? I created a jsFiddle that shows what I want to accomplish . Background Ember's model of navigation through an application uses HTML anchors. I have the following requirement: when a user clicks on a Handlebar linkTo helper to navigate to a new route destination , the browser should automatically scroll to an anchor inside the Handlebars template associated to that new route destination . Raghav RV Use jquery to scroll to a particular section. $('html,body').animate({ scrollTop: $("a[name=

Handlebars templates using ampersand and caret

为君一笑 提交于 2019-12-05 06:16:42
We found some old Handlebars templates which are working fine, but include some odd usage of Handlebars. The two strange ones are {{^is_question}}{{/is_question}} and {{& answer}} Neither of those are listed in the Handlerbars docs and there are no helpers defined. Anyone know what they do? The ^is_question appears to be used interchangeably with {{#if is_question}}. Maybe it is some deprecated shorthand notation? The template is compiled the same way we compile other templates: template = Handlebars.compile(ItemTemplate) Our handlebars version is: Handlebars.VERSION = "1.0.0-rc.3"; I've used

how to have grunt task render mustache partials to static HTML

十年热恋 提交于 2019-12-05 06:00:16
问题 Background I've been using grunt.js with a hogan.js task to build the static HTML for our internal docs. I'm learning JavaScript as I go, but I've gotten the task to work well enough for layouts and pages, but it would really help our workflow to have the hogan task render mustache partials to HTML, as in the example in this gist: https://gist.github.com/4132781 Current Setup and what I want to accomplish All of our mustache partials are in a folder called "partials". Ideally when the grunt

Evaluate two conditions in handlebar using ember

不羁岁月 提交于 2019-12-05 05:54:35
I was wondering if its possible to do something like this: {{#if ClientController.Client.number && PhoneController.hasLinesToInstall}} ... {{/if}}} Thanks, Juanitos I don't think it's possible to chain conditions like that in handlebars like that - I can't find anything about it in the documentation. You could nest them though, like this: {{#if ClientController.Client.number}} {{#if PhoneController.hasLinesToInstall}} ... {{/if}} {{/if}} That would achieve the same outcome. It's not supported out-of-the-box, but you can use the addon https://github.com/jmurphyau/ember-truth-helpers : ember

Handlebars if statement with index = some value

て烟熏妆下的殇ゞ 提交于 2019-12-05 05:30:35
I'm trying to create a table that populates each table cell with an object from a JSON file. My handlebars template just adds a with the data for each object. What I'm trying accomplish is for every 5th item a new row is created and then it continues populating out the table cells until the 10th item then it creates a new row etc. I've been reading up on @index. Is there some function that does something like {{#if @index / 5 == 0}} ? Otherwise is there something handlebars offers that could achieve the functionality I'm trying to do? I'm not confined to use a table I just figured that was the

How can I specify an alternative directory for my HandlebarsJS templates with the ember-rails gem?

浪尽此生 提交于 2019-12-05 05:16:43
I have a Rails application, and I'm using Ember on the front-end. I'd like to move the ember-related files down one level in the directory structure, but when I do, the templates no longer render. In the plain, vanilla, working version of the application, my directory structure is: ./app/ assets/ javascripts application.js ember-app.js routes.js store.js models/ controllers/ routes/ templates/ views/ with: application.js //= require jquery //= require jquery_ujs //= require handlebars //= require ember //= require ember-data //= require_self //= require ember-app App = Ember.Application.create