summaryrefslogtreecommitdiffstats
path: root/docs/compiler-api.md
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-11-28 22:58:21 -0600
committerkpdecker <kpdecker@gmail.com>2014-11-28 23:13:06 -0600
commit928ba56b9577fd6cd874f0a83178f1265a6d0526 (patch)
tree1c522b0869f663e076e38cf741eac7370c798f90 /docs/compiler-api.md
parent8a6796e5c09686b47945a35826d77680d589d07c (diff)
downloadhandlebars.js-928ba56b9577fd6cd874f0a83178f1265a6d0526.zip
handlebars.js-928ba56b9577fd6cd874f0a83178f1265a6d0526.tar.gz
handlebars.js-928ba56b9577fd6cd874f0a83178f1265a6d0526.tar.bz2
Rework strip flags to make clearer at in AST level
Rather than keeping state in the AST, which requires some gymnastics, we create a separate visitor flow which does the top down iteration necessary to calculate all of the state needed for proper whitespace control evaluation.
Diffstat (limited to 'docs/compiler-api.md')
-rw-r--r--docs/compiler-api.md22
1 files changed, 13 insertions, 9 deletions
diff --git a/docs/compiler-api.md b/docs/compiler-api.md
index 7e89b01..89dcc4c 100644
--- a/docs/compiler-api.md
+++ b/docs/compiler-api.md
@@ -45,28 +45,31 @@ interface Program <: Node {
body: [ Statement ];
blockParams: [ string ];
- strip: StripFlags | null;
}
```
### Statements
```java
-interface Statement <: Node {
- strip: StripFlags | null;
-}
+interface Statement <: Node { }
interface MustacheStatement <: Statement {
type: "MustacheStatement";
sexpr: Subexpression;
escaped: boolean;
+
+ strip: StripFlags | null;
}
interface BlockStatement <: Statement {
type: "BlockStatement";
sexpr: Subexpression;
- program: Program;
+ program: Program | null;
inverse: Program | null;
+
+ openStrip: StripFlags | null;
+ inverseStrip: StripFlags | null;
+ closeStrip: StripFlags | null;
}
interface PartialStatement <: Statement {
@@ -74,6 +77,7 @@ interface PartialStatement <: Statement {
sexpr: Subexpression;
indent: string;
+ strip: StripFlags | null;
}
interface ContentStatement <: Statement {
@@ -85,6 +89,8 @@ interface ContentStatement <: Statement {
interface CommentStatement <: Statement {
type: "CommentStatement";
value: string;
+
+ strip: StripFlags | null;
}
```
@@ -167,15 +173,13 @@ interface HashPair <: Node {
}
interface StripFlags {
- left: boolean;
- right: boolean;
+ open: boolean;
+ close: boolean;
}
```
`StripFlags` are used to signify whitespace control character that may have been entered on a given statement.
-TODO : Document what the flags mean or drop this from things like Program.
-
## AST Visitor
`Handlebars.Visitor` is available as a base class for general interaction with AST structures. This will by default traverse the entire tree and individual methods may be overridden to provide specific responses to particular nodes.