Ember.js - 从计算属性返回 unicode 字符 [英] Ember.js - Return unicode character from computed property

查看:17
本文介绍了Ember.js - 从计算属性返回 unicode 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从计算属性返回一个 unicode 字符,但是 & 一直被转义为 &.

I'm trying to return a unicode character from a computed property, but the & keeps getting escaped as &.

我什至尝试过像这样返回一个 Handlebars SafeString:

I've even tried returning a Handlebars SafeString like so:

return new Ember.Handlebars.SafeString("");

...产生相同的结果:

...which produces the same results: 

我怎样才能让它工作?

这可能与我在 {{input}}valueBinding 中使用计算属性有关> 帮手.SafeString 方法确实可以防止 & 被转义 if 我在别处使用该值.

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.

推荐答案

我刚刚创建了一个简单的 jsbin:http://jsbin.com/izurix/5/edit

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

基本上这样做不会为我返回任何&amp:

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')
});

此外,如果您不希望把手转义您的字符串,您应该使用 triple-slash {{{someValue}}}.

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

希望有帮助.

这篇关于Ember.js - 从计算属性返回 unicode 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆