1let AST = { 2 // Public API used to evaluate derived attributes regarding AST nodes 3 helpers: { 4 // a mustache is definitely a helper if: 5 // * it is an eligible helper, and 6 // * it has at least one parameter or hash segment 7 helperExpression: function(node) { 8 return ( 9 node.type === 'SubExpression' || 10 ((node.type === 'MustacheStatement' || 11 node.type === 'BlockStatement') && 12 !!((node.params && node.params.length) || node.hash)) 13 ); 14 }, 15 16 scopedId: function(path) { 17 return /^\.|this\b/.test(path.original); 18 }, 19 20 // an ID is simple if it only has one part, and that part is not 21 // `..` or `this`. 22 simpleId: function(path) { 23 return ( 24 path.parts.length === 1 && !AST.helpers.scopedId(path) && !path.depth 25 ); 26 } 27 } 28}; 29 30// Must be exported as an object rather than the root of the module as the jison lexer 31// must modify the object to operate properly. 32export default AST; 33