From 8f7be7190512a23107034eb78383cbb77f306f5e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 24 May 2013 08:42:11 -0700 Subject: [PATCH] Avoid escaping existing non-ascii characters in templates. [closes #278] Former-commit-id: a56581f3e323c0c47e4f26ef8dce13e90fb6c15c --- build/minify.js | 6 +++++- test/template/d.tpl | 2 +- test/test-build.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build/minify.js b/build/minify.js index b6c5d7654..1061b09f6 100755 --- a/build/minify.js +++ b/build/minify.js @@ -375,6 +375,7 @@ isAdvanced = mode == 'advanced', isMapped = this.isMapped, isSilent = this.isSilent, + isTemplate = this.isTemplate, options = closureOptions.slice(), outputPath = this.outputPath, mapPath = getMapPath(outputPath), @@ -400,6 +401,9 @@ if (isMapped) { options.push('--create_source_map=' + mapPath, '--source_map_format=V3'); } + if (isTemplate) { + options.push('--charset=UTF-8'); + } getJavaOptions(function(javaOptions) { var compiler = cp.spawn('java', javaOptions.concat('-jar', closurePath, options)); @@ -497,7 +501,7 @@ // 4. output // restrict lines to 500 characters for consistency with the Closure Compiler var stream = uglifyJS.OutputStream({ - 'ascii_only': true, + 'ascii_only': !this.isTemplate, 'comments': /@cc_on|@license|@preserve/i, 'max_line_len': 500, }); diff --git a/test/template/d.tpl b/test/template/d.tpl index c7a43bc1f..fdb97d1a4 100644 --- a/test/template/d.tpl +++ b/test/template/d.tpl @@ -1 +1 @@ -Hello {{ name }}! \ No newline at end of file +HallÄ {{ name }}! \ No newline at end of file diff --git a/test/test-build.js b/test/test-build.js index c1820730f..37cfdbdd0 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -652,7 +652,7 @@ vm.runInContext(data.source, context); equal(moduleId, expectedId, basename); - equal(_.templates.d(object.d), 'Hello Mustache!', basename); + equal(_.templates.d(object.d), 'HallÄ Mustache!', basename); delete _.templates; start(); });