aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/compile.js
diff options
context:
space:
mode:
authorIgor Minar2012-08-11 00:13:10 -0700
committerIgor Minar2012-08-13 14:33:56 -0700
commitdfe99836cd98c2a1b0f9bde6216bd44088de275a (patch)
treecf71c7d1311a716f56a4c55526765478493771e3 /src/ng/compile.js
parent0f37194fb7ce67c3719626d9e21d95a66538a0e4 (diff)
downloadangular.js-dfe99836cd98c2a1b0f9bde6216bd44088de275a.tar.bz2
fix($compile): denormalize directive templates
Since developers are allowed to customize start/end interpolation strings, but third-party directive creators don't know about these customizations, we should standardize on {{ }} in templates of reusable (third-party) directives. During the compilation, these templates are then denormalized to use whatever the custom start/end symbol is, effectively translating the template into the syntax of the runtime environment. This addresses an issue raised at http://goo.gl/e8VPV Existing code should not be affected by this change since project that do use custom interpolation markers are not expected to use {{ }} in existing directive templates.
Diffstat (limited to 'src/ng/compile.js')
-rw-r--r--src/ng/compile.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js
index 56dafc39..89f46af6 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -297,6 +297,15 @@ function $CompileProvider($provide) {
}
};
+ var startSymbol = $interpolate.startSymbol(),
+ endSymbol = $interpolate.endSymbol(),
+ denormalizeTemplate = (startSymbol == '{{' || endSymbol == '}}')
+ ? identity
+ : function denormalizeTemplate(template) {
+ return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol);
+ };
+
+
return compile;
//================================
@@ -579,6 +588,7 @@ function $CompileProvider($provide) {
if ((directiveValue = directive.template)) {
assertNoDuplicate('template', templateDirective, directive, $compileNode);
templateDirective = directive;
+ directiveValue = denormalizeTemplate(directiveValue);
if (directive.replace) {
$template = jqLite('<div>' +
@@ -898,6 +908,8 @@ function $CompileProvider($provide) {
success(function(content) {
var compileNode, tempTemplateAttrs, $template;
+ content = denormalizeTemplate(content);
+
if (replace) {
$template = jqLite('<div>' + trim(content) + '</div>').contents();
compileNode = $template[0];