Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mustacheExpression(expr: AST.MustacheStatement) {
let { path } = expr;
if (isLiteral(path)) {
this.opcode('literal', expr, path.value);
} else if (isBuiltInHelper(path)) {
this.builtInHelper(expr as AST.Call);
} else if (isArg(path)) {
this.arg([path]);
} else if (isHelperInvocation(expr)) {
this.prepareHelper(expr);
this.opcode('helper', expr, path.parts[0]);
} else if (path.this) {
this.opcode('get', expr, 0, path.parts);
} else if (isLocal(path, this.symbols)) {
let [head, ...parts] = path.parts;
this.opcode('get', expr, this.symbols.get(head), parts);
} else if (isSimplePath(path)) {
this.opcode('unknown', expr, path.parts[0]);
} else {
private expression(path: AST.Expression, context: ExpressionContext, expr: AST.Node) {
if (isLiteral(path)) {
this.opcode(['literal', path.value], expr);
} else if (path.type !== 'PathExpression') {
throw new SyntaxError(`Expected PathExpression, got ${path.type}`, path.loc);
} else if (isKeyword(expr)) {
this.keyword(expr as AST.Call);
} else {
this.path(path, context);
}
}
mustacheExpression(expr: AST.MustacheStatement) {
let { path } = expr;
if (isLiteral(path)) {
this.opcode(['literal', path.value], expr);
} else if (isKeyword(path)) {
this.keyword(expr as AST.Call);
} else if (isArgReference(path)) {
this.argReference([path]);
} else if (isInvocation(expr)) {
this.prepareInvocation(expr);
this.opcode(['helper', path.parts[0]], expr);
} else if (path.this) {
this.opcode(['get', [0, path.parts]], expr);
} else {
let [head, ...parts] = path.parts;
this.opcode(['freeVariable', [head, ...parts]], expr);
}
}
mustache([mustache]: [AST.MustacheStatement]) {
let { path } = mustache;
if (isLiteral(path)) {
this.expression(mustache.path, ExpressionContext.Expression, mustache);
this.opcode(['append', !mustache.escaped], mustache);
} else if (path.type !== 'PathExpression') {
throw new SyntaxError(`Expected PathExpression, got ${path.type}`, path.loc);
} else if (isYield(path)) {
let to = assertValidYield(mustache);
this.yield(to, mustache);
} else if (isPartial(path)) {
let params = assertValidPartial(mustache);
this.partial(params, mustache);
} else if (isDebugger(path)) {
assertValidDebuggerUsage(mustache);
this.debugger('debugger', mustache);
} else if (isKeyword(mustache)) {
this.keyword(mustache);
this.opcode(['append', !mustache.escaped], mustache);