Avoid escaping existing non-ascii characters in templates. [closes #278]

Former-commit-id: a56581f3e323c0c47e4f26ef8dce13e90fb6c15c
This commit is contained in:
John-David Dalton
2013-05-24 08:42:11 -07:00
parent 5d583637c4
commit 8f7be71905
3 changed files with 7 additions and 3 deletions

View File

@@ -375,6 +375,7 @@
isAdvanced = mode == 'advanced', isAdvanced = mode == 'advanced',
isMapped = this.isMapped, isMapped = this.isMapped,
isSilent = this.isSilent, isSilent = this.isSilent,
isTemplate = this.isTemplate,
options = closureOptions.slice(), options = closureOptions.slice(),
outputPath = this.outputPath, outputPath = this.outputPath,
mapPath = getMapPath(outputPath), mapPath = getMapPath(outputPath),
@@ -400,6 +401,9 @@
if (isMapped) { if (isMapped) {
options.push('--create_source_map=' + mapPath, '--source_map_format=V3'); options.push('--create_source_map=' + mapPath, '--source_map_format=V3');
} }
if (isTemplate) {
options.push('--charset=UTF-8');
}
getJavaOptions(function(javaOptions) { getJavaOptions(function(javaOptions) {
var compiler = cp.spawn('java', javaOptions.concat('-jar', closurePath, options)); var compiler = cp.spawn('java', javaOptions.concat('-jar', closurePath, options));
@@ -497,7 +501,7 @@
// 4. output // 4. output
// restrict lines to 500 characters for consistency with the Closure Compiler // restrict lines to 500 characters for consistency with the Closure Compiler
var stream = uglifyJS.OutputStream({ var stream = uglifyJS.OutputStream({
'ascii_only': true, 'ascii_only': !this.isTemplate,
'comments': /@cc_on|@license|@preserve/i, 'comments': /@cc_on|@license|@preserve/i,
'max_line_len': 500, 'max_line_len': 500,
}); });

View File

@@ -1 +1 @@
Hello {{ name }}! Hallå {{ name }}!

View File

@@ -652,7 +652,7 @@
vm.runInContext(data.source, context); vm.runInContext(data.source, context);
equal(moduleId, expectedId, basename); equal(moduleId, expectedId, basename);
equal(_.templates.d(object.d), 'Hello Mustache!', basename); equal(_.templates.d(object.d), 'Hallå Mustache!', basename);
delete _.templates; delete _.templates;
start(); start();
}); });