使用Ember.js夹具数据,有没有办法绕过引号?

时间:2013-12-13 22:31:08

标签: ember.js

为了使应用程序正常工作,我必须使用反斜杠转义引号。有没有办法绕过Ember夹具数据中的引号?

html: "<li>\"Hello, I'm HTML!\"</li>"

我不知道从哪里开始。这是我在哪里......

App = Ember.Application.create();

/****************************************************
ROUTER AND STORE SETUP
****************************************************/

App.Router.map(function() {
  this.resource('posts',{path: "/"});
  this.resource('post', { path: '/:post_id'});
});

/****************************************************
HELPERS
****************************************************/

Ember.Handlebars.helper('rawhtml', function(value, options) {
  return new Handlebars.SafeString(value);
});

/****************************************************
ROUTES
****************************************************/

App.PostsRoute = Ember.Route.extend({
  model: function() {
    return posts;
  }
});

/****************************************************
CONTROLLERS
****************************************************/

App.PostsController = Ember.ArrayController.extend({
    codePosts: Ember.computed.filterBy('model', 'category', 'Code')
});

/****************************************************
FIXTURES
****************************************************/

var posts = [{
category: 'Code',
id: 'cssbestpractices',
title: 'CSS Best Practices',
date: { weekday: 'Friday', month: 'November', day: '1', year: '2013' },
html: "<li>\"Hello, I'm HTML!\"</li>"
}, {
category: 'Code',
id: 'namingfiles',
title: 'Naming Files',
date: { weekday: "Thursday", month: "October", day: "24", year: "2013" },
html: "<li>Hello, I am HTML!</li>"
}, {
category: 'Code',
id: 'seo-copy-block',
title: 'SEO Copy Block',
date: { weekday: "Thursday", month: "October", day: "24", year: "2013" },
html: "<li>Hello, I am HTML!</li>"
}, {
category: 'Pizza',
id: 'pizza-delivery',
title: 'Pizza Delivery',
date: { weekday: "Tuesday", month: "November", day: "5", year: "2013" },
html: "<li>Hello, I am HTML!</li>"
}];

JSFiddle。谢谢。

1 个答案:

答案 0 :(得分:0)

使用单引号,这是javascript,真的不是ember,我喜欢转义超过&apos;

'<li>"Hello, I&apos;m HTML!"</li>'