Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handlebars Helpers & Nodejs Trouble
Handlebars.registerHelper("testHelper", function(options) {
console.log('testHelper')
return 'testHelper'
})
var template = "{{testHelper}}"
var ret = Handlebars.parse(template).statements
if (typeof ret[0] == 'undefined' || typeof ret[0].type == 'undefined' || ret[0].type != 'content') {
console.log('tags', ret, 'template', template)
}
/*
logs:
tags [ { firstLine: 1,
firstColumn: 0,
lastColumn: 14,
lastLine: 1,
type: 'mustache',
strip: { left: false, right: false },
escaped: true,
sexpr:
{ firstLine: 1,
firstColumn: 2,
lastColumn: 12,
lastLine: 1,
type: 'sexpr',
hash: undefined,
id: [Object],
params: [],
isHelper: false,
eligibleHelper: true,
isRoot: true },
id:
{ firstLine: 1,
firstColumn: 2,
lastColumn: 12,
lastLine: 1,
type: 'ID',
original: 'testHelper',
parts: [Object],
string: 'testHelper',
depth: 0,
idName: 'testHelper',
isSimple: true,
stringModeValue: 'testHelper' },
params: [],
hash: undefined,
eligibleHelper: true,
isHelper: false } ] template {{testHelper}}
tags [] template
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.