summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2012-12-23 20:29:36 -0800
committerYehuda Katz <wycats@gmail.com>2012-12-23 20:29:36 -0800
commitbf4c813db03bbc3ab63e33256d7a6824cbd35e57 (patch)
tree7957c5ae1a54dea6ca8fbf5cd08cc037765ed560 /lib/handlebars/compiler
parent070e12f76f251fc038956f61f132dec99a898cd2 (diff)
parentb58c2dd0ad9b3454c2f1b39e5680d473693514f9 (diff)
downloadhandlebars.js-bf4c813db03bbc3ab63e33256d7a6824cbd35e57.zip
handlebars.js-bf4c813db03bbc3ab63e33256d7a6824cbd35e57.tar.gz
handlebars.js-bf4c813db03bbc3ab63e33256d7a6824cbd35e57.tar.bz2
Merge pull request #389 from leshill/partial_names
Partials can be paths
Diffstat (limited to 'lib/handlebars/compiler')
-rw-r--r--lib/handlebars/compiler/ast.js16
-rw-r--r--lib/handlebars/compiler/compiler.js4
-rw-r--r--lib/handlebars/compiler/printer.js6
3 files changed, 16 insertions, 10 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index 25abe0a..459b863 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -33,13 +33,10 @@ var Handlebars = require('./base');
// pass or at runtime.
};
- Handlebars.AST.PartialNode = function(id, context) {
- this.type = "partial";
-
- // TODO: disallow complex IDs
-
- this.id = id;
- this.context = context;
+ Handlebars.AST.PartialNode = function(partialName, context) {
+ this.type = "partial";
+ this.partialName = partialName;
+ this.context = context;
};
var verifyMatch = function(open, close) {
@@ -93,6 +90,11 @@ var Handlebars = require('./base');
this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
};
+ Handlebars.AST.PartialNameNode = function(name) {
+ this.type = "PARTIAL_NAME";
+ this.name = name;
+ };
+
Handlebars.AST.DataNode = function(id) {
this.type = "DATA";
this.id = id;
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index 57516a5..297a553 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -160,7 +160,7 @@ Handlebars.JavaScriptCompiler = function() {};
},
partial: function(partial) {
- var id = partial.id;
+ var partialName = partial.partialName;
this.usePartial = true;
if(partial.context) {
@@ -169,7 +169,7 @@ Handlebars.JavaScriptCompiler = function() {};
this.opcode('push', 'depth0');
}
- this.opcode('invokePartial', id.original);
+ this.opcode('invokePartial', partialName.name);
this.opcode('append');
},
diff --git a/lib/handlebars/compiler/printer.js b/lib/handlebars/compiler/printer.js
index 7a42a66..853a4ca 100644
--- a/lib/handlebars/compiler/printer.js
+++ b/lib/handlebars/compiler/printer.js
@@ -72,7 +72,7 @@ Handlebars.PrintVisitor.prototype.mustache = function(mustache) {
};
Handlebars.PrintVisitor.prototype.partial = function(partial) {
- var content = this.accept(partial.id);
+ var content = this.accept(partial.partialName);
if(partial.context) { content = content + " " + this.accept(partial.context); }
return this.pad("{{> " + content + " }}");
};
@@ -111,6 +111,10 @@ Handlebars.PrintVisitor.prototype.ID = function(id) {
}
};
+Handlebars.PrintVisitor.prototype.PARTIAL_NAME = function(partialName) {
+ return "PARTIAL:" + partialName.name;
+};
+
Handlebars.PrintVisitor.prototype.DATA = function(data) {
return "@" + data.id;
};