handlebars-jaylinski 4.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.markdown +169 -0
- package/bin/.eslintrc.js +6 -0
- package/bin/handlebars +176 -0
- package/dist/amd/handlebars/base.js +106 -0
- package/dist/amd/handlebars/compiler/ast.js +31 -0
- package/dist/amd/handlebars/compiler/base.js +45 -0
- package/dist/amd/handlebars/compiler/code-gen.js +165 -0
- package/dist/amd/handlebars/compiler/compiler.js +562 -0
- package/dist/amd/handlebars/compiler/helpers.js +228 -0
- package/dist/amd/handlebars/compiler/javascript-compiler.js +1150 -0
- package/dist/amd/handlebars/compiler/parser.js +737 -0
- package/dist/amd/handlebars/compiler/printer.js +186 -0
- package/dist/amd/handlebars/compiler/visitor.js +138 -0
- package/dist/amd/handlebars/compiler/whitespace-control.js +219 -0
- package/dist/amd/handlebars/decorators/inline.js +25 -0
- package/dist/amd/handlebars/decorators.js +16 -0
- package/dist/amd/handlebars/exception.js +64 -0
- package/dist/amd/handlebars/helpers/block-helper-missing.js +35 -0
- package/dist/amd/handlebars/helpers/each.js +99 -0
- package/dist/amd/handlebars/helpers/helper-missing.js +22 -0
- package/dist/amd/handlebars/helpers/if.js +41 -0
- package/dist/amd/handlebars/helpers/log.js +24 -0
- package/dist/amd/handlebars/helpers/lookup.js +14 -0
- package/dist/amd/handlebars/helpers/with.js +38 -0
- package/dist/amd/handlebars/helpers.js +44 -0
- package/dist/amd/handlebars/internal/create-new-lookup-object.js +22 -0
- package/dist/amd/handlebars/internal/proto-access.js +71 -0
- package/dist/amd/handlebars/internal/wrapHelper.js +21 -0
- package/dist/amd/handlebars/logger.js +44 -0
- package/dist/amd/handlebars/no-conflict.js +28 -0
- package/dist/amd/handlebars/runtime.js +356 -0
- package/dist/amd/handlebars/safe-string.js +15 -0
- package/dist/amd/handlebars/utils.js +126 -0
- package/dist/amd/handlebars.js +52 -0
- package/dist/amd/handlebars.runtime.js +44 -0
- package/dist/amd/precompiler.js +314 -0
- package/dist/cjs/handlebars/base.js +116 -0
- package/dist/cjs/handlebars/compiler/ast.js +31 -0
- package/dist/cjs/handlebars/compiler/base.js +57 -0
- package/dist/cjs/handlebars/compiler/code-gen.js +168 -0
- package/dist/cjs/handlebars/compiler/compiler.js +566 -0
- package/dist/cjs/handlebars/compiler/helpers.js +228 -0
- package/dist/cjs/handlebars/compiler/javascript-compiler.js +1158 -0
- package/dist/cjs/handlebars/compiler/parser.js +737 -0
- package/dist/cjs/handlebars/compiler/printer.js +186 -0
- package/dist/cjs/handlebars/compiler/visitor.js +140 -0
- package/dist/cjs/handlebars/compiler/whitespace-control.js +221 -0
- package/dist/cjs/handlebars/decorators/inline.js +29 -0
- package/dist/cjs/handlebars/decorators.js +16 -0
- package/dist/cjs/handlebars/exception.js +64 -0
- package/dist/cjs/handlebars/helpers/block-helper-missing.js +39 -0
- package/dist/cjs/handlebars/helpers/each.js +104 -0
- package/dist/cjs/handlebars/helpers/helper-missing.js +25 -0
- package/dist/cjs/handlebars/helpers/if.js +46 -0
- package/dist/cjs/handlebars/helpers/log.js +26 -0
- package/dist/cjs/handlebars/helpers/lookup.js +16 -0
- package/dist/cjs/handlebars/helpers/with.js +43 -0
- package/dist/cjs/handlebars/helpers.js +56 -0
- package/dist/cjs/handlebars/internal/create-new-lookup-object.js +22 -0
- package/dist/cjs/handlebars/internal/proto-access.js +73 -0
- package/dist/cjs/handlebars/internal/wrapHelper.js +19 -0
- package/dist/cjs/handlebars/logger.js +47 -0
- package/dist/cjs/handlebars/no-conflict.js +30 -0
- package/dist/cjs/handlebars/runtime.js +372 -0
- package/dist/cjs/handlebars/safe-string.js +15 -0
- package/dist/cjs/handlebars/utils.js +124 -0
- package/dist/cjs/handlebars.js +66 -0
- package/dist/cjs/handlebars.runtime.js +66 -0
- package/dist/cjs/precompiler.js +328 -0
- package/dist/handlebars.amd.js +4639 -0
- package/dist/handlebars.amd.min.js +29 -0
- package/dist/handlebars.js +5972 -0
- package/dist/handlebars.min.js +29 -0
- package/dist/handlebars.runtime.amd.js +1302 -0
- package/dist/handlebars.runtime.amd.min.js +27 -0
- package/dist/handlebars.runtime.js +2563 -0
- package/dist/handlebars.runtime.min.js +27 -0
- package/lib/.eslintrc.js +8 -0
- package/lib/handlebars/base.js +94 -0
- package/lib/handlebars/compiler/ast.js +32 -0
- package/lib/handlebars/compiler/base.js +34 -0
- package/lib/handlebars/compiler/code-gen.js +171 -0
- package/lib/handlebars/compiler/compiler.js +594 -0
- package/lib/handlebars/compiler/helpers.js +219 -0
- package/lib/handlebars/compiler/javascript-compiler.js +1293 -0
- package/lib/handlebars/compiler/parser.js +622 -0
- package/lib/handlebars/compiler/printer.js +178 -0
- package/lib/handlebars/compiler/visitor.js +136 -0
- package/lib/handlebars/compiler/whitespace-control.js +234 -0
- package/lib/handlebars/decorators/inline.js +22 -0
- package/lib/handlebars/decorators.js +5 -0
- package/lib/handlebars/exception.js +68 -0
- package/lib/handlebars/helpers/block-helper-missing.js +35 -0
- package/lib/handlebars/helpers/each.js +101 -0
- package/lib/handlebars/helpers/helper-missing.js +15 -0
- package/lib/handlebars/helpers/if.js +33 -0
- package/lib/handlebars/helpers/log.js +19 -0
- package/lib/handlebars/helpers/lookup.js +9 -0
- package/lib/handlebars/helpers/with.js +39 -0
- package/lib/handlebars/helpers.js +26 -0
- package/lib/handlebars/internal/create-new-lookup-object.js +11 -0
- package/lib/handlebars/internal/proto-access.js +70 -0
- package/lib/handlebars/internal/wrapHelper.js +13 -0
- package/lib/handlebars/logger.js +39 -0
- package/lib/handlebars/no-conflict.js +23 -0
- package/lib/handlebars/runtime.js +450 -0
- package/lib/handlebars/safe-string.js +10 -0
- package/lib/handlebars/utils.js +116 -0
- package/lib/handlebars.js +46 -0
- package/lib/handlebars.runtime.js +37 -0
- package/lib/index.js +26 -0
- package/lib/precompiler.js +341 -0
- package/package.json +135 -0
- package/release-notes.md +1101 -0
- package/runtime.d.ts +5 -0
- package/runtime.js +3 -0
- package/types/index.d.ts +422 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import Exception from '../exception';
|
|
2
|
+
|
|
3
|
+
function validateClose(open, close) {
|
|
4
|
+
close = close.path ? close.path.original : close;
|
|
5
|
+
|
|
6
|
+
if (open.path.original !== close) {
|
|
7
|
+
let errorNode = { loc: open.path.loc };
|
|
8
|
+
|
|
9
|
+
throw new Exception(
|
|
10
|
+
open.path.original + " doesn't match " + close,
|
|
11
|
+
errorNode
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function SourceLocation(source, locInfo) {
|
|
17
|
+
this.source = source;
|
|
18
|
+
this.start = {
|
|
19
|
+
line: locInfo.first_line,
|
|
20
|
+
column: locInfo.first_column
|
|
21
|
+
};
|
|
22
|
+
this.end = {
|
|
23
|
+
line: locInfo.last_line,
|
|
24
|
+
column: locInfo.last_column
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function id(token) {
|
|
29
|
+
if (/^\[.*\]$/.test(token)) {
|
|
30
|
+
return token.substring(1, token.length - 1);
|
|
31
|
+
} else {
|
|
32
|
+
return token;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function stripFlags(open, close) {
|
|
37
|
+
return {
|
|
38
|
+
open: open.charAt(2) === '~',
|
|
39
|
+
close: close.charAt(close.length - 3) === '~'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function stripComment(comment) {
|
|
44
|
+
return comment.replace(/^\{\{~?!-?-?/, '').replace(/-?-?~?\}\}$/, '');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function preparePath(data, parts, loc) {
|
|
48
|
+
loc = this.locInfo(loc);
|
|
49
|
+
|
|
50
|
+
let original = data ? '@' : '',
|
|
51
|
+
dig = [],
|
|
52
|
+
depth = 0;
|
|
53
|
+
|
|
54
|
+
for (let i = 0, l = parts.length; i < l; i++) {
|
|
55
|
+
let part = parts[i].part,
|
|
56
|
+
// If we have [] syntax then we do not treat path references as operators,
|
|
57
|
+
// i.e. foo.[this] resolves to approximately context.foo['this']
|
|
58
|
+
isLiteral = parts[i].original !== part;
|
|
59
|
+
original += (parts[i].separator || '') + part;
|
|
60
|
+
|
|
61
|
+
if (!isLiteral && (part === '..' || part === '.' || part === 'this')) {
|
|
62
|
+
if (dig.length > 0) {
|
|
63
|
+
throw new Exception('Invalid path: ' + original, { loc });
|
|
64
|
+
} else if (part === '..') {
|
|
65
|
+
depth++;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
dig.push(part);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
type: 'PathExpression',
|
|
74
|
+
data,
|
|
75
|
+
depth,
|
|
76
|
+
parts: dig,
|
|
77
|
+
original,
|
|
78
|
+
loc
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function prepareMustache(path, params, hash, open, strip, locInfo) {
|
|
83
|
+
// Must use charAt to support IE pre-10
|
|
84
|
+
let escapeFlag = open.charAt(3) || open.charAt(2),
|
|
85
|
+
escaped = escapeFlag !== '{' && escapeFlag !== '&';
|
|
86
|
+
|
|
87
|
+
let decorator = /\*/.test(open);
|
|
88
|
+
return {
|
|
89
|
+
type: decorator ? 'Decorator' : 'MustacheStatement',
|
|
90
|
+
path,
|
|
91
|
+
params,
|
|
92
|
+
hash,
|
|
93
|
+
escaped,
|
|
94
|
+
strip,
|
|
95
|
+
loc: this.locInfo(locInfo)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function prepareRawBlock(openRawBlock, contents, close, locInfo) {
|
|
100
|
+
validateClose(openRawBlock, close);
|
|
101
|
+
|
|
102
|
+
locInfo = this.locInfo(locInfo);
|
|
103
|
+
let program = {
|
|
104
|
+
type: 'Program',
|
|
105
|
+
body: contents,
|
|
106
|
+
strip: {},
|
|
107
|
+
loc: locInfo
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
type: 'BlockStatement',
|
|
112
|
+
path: openRawBlock.path,
|
|
113
|
+
params: openRawBlock.params,
|
|
114
|
+
hash: openRawBlock.hash,
|
|
115
|
+
program,
|
|
116
|
+
openStrip: {},
|
|
117
|
+
inverseStrip: {},
|
|
118
|
+
closeStrip: {},
|
|
119
|
+
loc: locInfo
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function prepareBlock(
|
|
124
|
+
openBlock,
|
|
125
|
+
program,
|
|
126
|
+
inverseAndProgram,
|
|
127
|
+
close,
|
|
128
|
+
inverted,
|
|
129
|
+
locInfo
|
|
130
|
+
) {
|
|
131
|
+
if (close && close.path) {
|
|
132
|
+
validateClose(openBlock, close);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let decorator = /\*/.test(openBlock.open);
|
|
136
|
+
|
|
137
|
+
program.blockParams = openBlock.blockParams;
|
|
138
|
+
|
|
139
|
+
let inverse, inverseStrip;
|
|
140
|
+
|
|
141
|
+
if (inverseAndProgram) {
|
|
142
|
+
if (decorator) {
|
|
143
|
+
throw new Exception(
|
|
144
|
+
'Unexpected inverse block on decorator',
|
|
145
|
+
inverseAndProgram
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (inverseAndProgram.chain) {
|
|
150
|
+
inverseAndProgram.program.body[0].closeStrip = close.strip;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
inverseStrip = inverseAndProgram.strip;
|
|
154
|
+
inverse = inverseAndProgram.program;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (inverted) {
|
|
158
|
+
inverted = inverse;
|
|
159
|
+
inverse = program;
|
|
160
|
+
program = inverted;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
type: decorator ? 'DecoratorBlock' : 'BlockStatement',
|
|
165
|
+
path: openBlock.path,
|
|
166
|
+
params: openBlock.params,
|
|
167
|
+
hash: openBlock.hash,
|
|
168
|
+
program,
|
|
169
|
+
inverse,
|
|
170
|
+
openStrip: openBlock.strip,
|
|
171
|
+
inverseStrip,
|
|
172
|
+
closeStrip: close && close.strip,
|
|
173
|
+
loc: this.locInfo(locInfo)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function prepareProgram(statements, loc) {
|
|
178
|
+
if (!loc && statements.length) {
|
|
179
|
+
const firstLoc = statements[0].loc,
|
|
180
|
+
lastLoc = statements[statements.length - 1].loc;
|
|
181
|
+
|
|
182
|
+
/* istanbul ignore else */
|
|
183
|
+
if (firstLoc && lastLoc) {
|
|
184
|
+
loc = {
|
|
185
|
+
source: firstLoc.source,
|
|
186
|
+
start: {
|
|
187
|
+
line: firstLoc.start.line,
|
|
188
|
+
column: firstLoc.start.column
|
|
189
|
+
},
|
|
190
|
+
end: {
|
|
191
|
+
line: lastLoc.end.line,
|
|
192
|
+
column: lastLoc.end.column
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
type: 'Program',
|
|
200
|
+
body: statements,
|
|
201
|
+
strip: {},
|
|
202
|
+
loc: loc
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function preparePartialBlock(open, program, close, locInfo) {
|
|
207
|
+
validateClose(open, close);
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
type: 'PartialBlockStatement',
|
|
211
|
+
name: open.path,
|
|
212
|
+
params: open.params,
|
|
213
|
+
hash: open.hash,
|
|
214
|
+
program,
|
|
215
|
+
openStrip: open.strip,
|
|
216
|
+
closeStrip: close && close.strip,
|
|
217
|
+
loc: this.locInfo(locInfo)
|
|
218
|
+
};
|
|
219
|
+
}
|