Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
).chain(function (name) {
return p.alt(
p.string("/}}").desc("self-closed tag '/}}'"),
p.string("}}").then(defineInner.skip(p.string('{{/define}}')))
).map(function (contents) {
return {
name: name,
contents: contents
};
});
});
}
throw e;
}
return result.value;
};
var basicString = p.regex(/(?!{{)[\s\S]+?(?={{)/)
.desc('non-template chars');
var variableName = p.regex(/\s*(?!\d)(\.|(?:(?:[^"\.\s\,=}/]\.?)+))/, 1)
.desc('variable name')
.map(function (x) {
return {type: 'property', value: x};
});
var trueLiteral = p.string('true').skip(p.optWhitespace)
.result({type: 'boolean', value: true});
var falseLiteral = p.string('false').skip(p.optWhitespace)
.result({type: 'boolean', value: false});
var booleanLiteral = p.alt(trueLiteral, falseLiteral).desc('boolean');
var numberLiteral = p.regex(/-?(0|[1-9]\d*)([.]\d+)?(e[+-]?\d+)?/i)
.skip(p.optWhitespace)
.desc('numeral')
.map(function (x) {
return {type: 'number', value: Number(x)};
});
var stringLiteral = p.regex(/"((?:\\.|.)*?)"/, 1)
.skip(p.optWhitespace)
).chain(function (name) {
return p.alt(
p.string("/}}").desc("self-closed tag '/}}'"),
p.string("}}").then(defineInner.skip(p.string('{{/define}}')))
).map(function (contents) {
return {
name: name,
contents: contents
};
});
});
else {
args.push(x);
}
}
return {
args: args,
kwargs: kwargs
};
});
var defineInner = p.regex(/(?!{{[\/#]define[\s}])[\s\S]+?(?={{[\/#]define[\s}])/)
.desc('template definition block');
var defineTag = p.seqMap(
p.optWhitespace,
p.string("{{#define").desc("{{#define..."),
p.whitespace,
variableName.desc('definition name'),
function (before, define, _, name) {
return name.value;
}
).chain(function (name) {
return p.alt(
p.string("/}}").desc("self-closed tag '/}}'"),
p.string("}}").then(defineInner.skip(p.string('{{/define}}')))
).map(function (contents) {
return {
name: name,
contents: contents
};
});
});
return result.value;
};
var basicString = p.regex(/(?!{{)[\s\S]+?(?={{)/)
.desc('non-template chars');
var variableName = p.regex(/\s*(?!\d)(\.|(?:(?:[^"\.\s\,=}/]\.?)+))/, 1)
.desc('variable name')
.map(function (x) {
return {type: 'property', value: x};
});
var trueLiteral = p.string('true').skip(p.optWhitespace)
.result({type: 'boolean', value: true});
var falseLiteral = p.string('false').skip(p.optWhitespace)
.result({type: 'boolean', value: false});
var booleanLiteral = p.alt(trueLiteral, falseLiteral).desc('boolean');
var numberLiteral = p.regex(/-?(0|[1-9]\d*)([.]\d+)?(e[+-]?\d+)?/i)
.skip(p.optWhitespace)
.desc('numeral')
.map(function (x) {
return {type: 'number', value: Number(x)};
});
var stringLiteral = p.regex(/"((?:\\.|.)*?)"/, 1)
.skip(p.optWhitespace)
.desc('quoted string')
.map(interpretEscapes)
.map(function (x) {