handlebars.js

Ember.js - Return unicode character from computed property

拥有回忆 提交于 2019-12-02 08:39:40
问题 I'm trying to return a unicode character from a computed property, but the & keeps getting escaped as & . I've even tried returning a Handlebars SafeString like so: return new Ember.Handlebars.SafeString(""); ...which produces the same results:  How can I get this working? Edit: This is probably related to the fact that I'm using the computed property in the valueBinding of an {{input}} helper. The SafeString method does keep the & from being escaped if I use the value elsewhere. 回答1

How can we custom sort JavaScript object keys?

烈酒焚心 提交于 2019-12-02 07:44:43
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 here is loop and sort but it sorts in A-Z pattern and not in the order I've specified the array in.

Ember.js - Return unicode character from computed property

孤街醉人 提交于 2019-12-02 06:38:45
I'm trying to return a unicode character from a computed property, but the & keeps getting escaped as & . I've even tried returning a Handlebars SafeString like so: return new Ember.Handlebars.SafeString(""); ...which produces the same results:  How can I get this working? Edit: This is probably related to the fact that I'm using the computed property in the valueBinding of an {{input}} helper. The SafeString method does keep the & from being escaped if I use the value elsewhere. I just created a simple jsbin: http://jsbin.com/izurix/5/edit Basically doing this does not return any

How to render component/helper by name from instance field?

谁都会走 提交于 2019-12-02 05:35:24
Is there way to use component from controller/view field So instead of using {{contact-select label="Label:" contacts=form.prop}} // or {{input-field label="Label:" contacts=form.prop}} // or {{datepicker-component label="Label:" contacts=form.prop}} use some like {{context.helperName label="Label:" contacts=form.prop}} I try use ember-helpers-render-component but it doesn't take component name from property You can use the component helper that was introduced in 1.11.0. Unfortunately there was no built-in way to do it before 1.11.0. If you're not able to upgrade, this thread can point you in

../this returns the view object inside inner loop when the parent and child have the same value

不打扰是莪最后的温柔 提交于 2019-12-02 04:19:14
I am just starting with handlebars and I am trying to do a simple double for loop in order to have all the day's time with 15 minute intervals. A very weird thing is happening where if the child and parent have the same values, the view object is being returned instead. This is my code: var handlebarsExpress = require('express-handlebars').create({ helpers: { for: function(from, to, incr, block) { var accum = ''; for(var i = from; i <= to; i += incr) { accum += block.fn(i); } return accum; } } }); app.engine('handlebars', handlebarsExpress.engine); app.set('view engine', 'handlebars'); ... ...

Second dropdown not calling EveryTime Based on First drop down

旧巷老猫 提交于 2019-12-02 03:45:58
I have two drop down list using ember. I have facing issue if change first drop down value not calling every time second dropdown values . Here I have added my complete code . please tell me what i did wrong this code <script type="text/x-handlebars"> <h2>Welcome to Ember.js</h2> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="index"> <div> {{view "select" content=model prompt="Please select a name" selectionBinding="controllers.comboBox.model" optionValuePath="content.title" optionLabelPath="content.body" }} </div> {{input type="hidden" value=controllers.comboBox

Generating a loop counter in Ember.js #each

夙愿已清 提交于 2019-12-02 03:33:13
问题 I'm finding the restrictions of handlebar templates in Ember.js to be absolutely crippling. You can't execute arbitrary javascript. All you get is a fixed set of abilities (if/else, each, action, view, outlet) and the ability to output the value of a property on the current context object. Which means I cannot figure out how to do something as simple as utilizing a loop counter in order to, for example, slap positional IDs on an html element inside a loop based on it's position in the

Transition from one route to another with a different model in Emberjs

纵饮孤独 提交于 2019-12-02 02:50:44
问题 I have a search page where we are getting different types of search results. In the list of search results I would like to use {{#linkTo 'someResources.someResource' result}}{{result.Name}}{{/linkTo}} And on the route someResources.someResource I want to use a totally different model than on the search page. How do I do that? When I click on the link for the linkTo it doesn't load the model again, instead it tries to use the model named result here. So what I would like to do is to reload the

Concatenation string with variable in emblem.js

蹲街弑〆低调 提交于 2019-12-02 02:03:59
I need in Emblem.js to transmit to i18n helper concatenated string constant with variable value, How can i do it? each item in model.items div t "dict.{{item}}" returns error Missing translation for key "dict.{{item}}" If you're using Handlebars 1.3+, you can use a subexpression . First, write a string concatenation helper: Ember.Handlebars.helper('concat', function (a, b) { return a + b; }); Then use it like this (sorry, I don't know Emblem so I'm going to use the normal stache syntax): {{t (concat 'dict.' item)}} 来源: https://stackoverflow.com/questions/29346824/concatenation-string-with

Link interpolation i18n

余生颓废 提交于 2019-12-02 01:59:25
问题 I use ember-i18n to handle multiples langages in my project, and I need to insert a link inside a translation (with interpolation). Any idea ? 回答1: Response from @jamesarosen on Github : You can't use the {{link-to}} helper inside a translation because it emits a DOM node, not a String. But you can use ember-href-to addon to generate URLs. In JavaScript: // some-thing/component.js: import { hrefTo } from 'ember-href-to/helpers/href-to'; text: Ember.computed('i18n.locale', function() { const