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:


I just created a simple jsbin: http://jsbin.com/izurix/5/edit

Basically doing this does not return any &amp for me:

App.ApplicationController = Ember.ObjectController.extend({
  value: "",
  someValue: function() {
    return new Handlebars.SafeString(this.get('value'));
  }.property('value')
});

Furthermore if you don't want that handlebars escapes your string you should use triple-slash {{{someValue}}}.

Hope it helps.



来源:https://stackoverflow.com/questions/18189097/ember-js-return-unicode-character-from-computed-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!