Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow handlebars escaped moustache tags #206

Merged
merged 1 commit into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/services/ember-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export default Ember.Service.extend({
// let templateCode = Ember.HTMLBars.precompile(code || '');

// Compiles all templates at runtime.
return this.compileJs('export default Ember.HTMLBars.compile(`' + (code || '') + '`);', filePath);
const mungedCode = (code || '').replace(/\\/g, "\\\\"); // Prevent backslashes from being escaped
return this.compileJs('export default Ember.HTMLBars.compile(`' + mungedCode + '`);', filePath);
},

compileCss(code, moduleName) {
Expand Down
31 changes: 31 additions & 0 deletions tests/acceptance/escape-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'ember-twiddle/tests/helpers/start-app';

module('Acceptance | escaping moustaches', {
beforeEach: function() {
this.application = startApp();
},

afterEach: function() {
Ember.run(this.application, 'destroy');
}
});

test('Able to escape moustache tag', function(assert) {

const files = [
{
filename: "application.template.hbs",
content: "\\{{Moustache}}"
}
];

runGist(files);

andThen(function() {
const outputDiv = 'div';

assert.equal(outputContents(outputDiv), '{{Moustache}}', 'Moustache tag is escaped');
});
});