@@ -366,7 +366,10 @@ function print(path, options, print) {
366366 ] ;
367367 }
368368 case "PathExpression" :
369- return printPathExpression ( node ) ;
369+ return printPathExpression ( node , print ) ;
370+
371+ case "AtHead" :
372+ return node . name ;
370373
371374 case "BooleanLiteral" :
372375 return String ( node . value ) ;
@@ -386,6 +389,8 @@ function print(path, options, print) {
386389 case "NullLiteral" :
387390 return "null" ;
388391
392+ case "VarHead" : // Handled in `printPathExpression`
393+ case "ThisHead" : // Handled in `printPathExpression`
389394 default :
390395 /* c8 ignore next */
391396 throw new UnexpectedNodeError ( node , "Handlebars" ) ;
@@ -786,12 +791,12 @@ const isPathExpressionPartNeedBrackets = (part, index) =>
786791 Array . prototype . some . call ( part , ( character ) =>
787792 PATH_EXPRESSION_FORBIDDEN_CHARACTERS . has ( character ) ,
788793 ) ;
789- // TODO[ @fisker ]: Print `head` via ` print`
790- function printPathExpression ( node ) {
791- if (
792- node . head . type === "AtHead" ||
793- ( node . tail . length === 0 && node . original . includes ( "/" ) )
794- ) {
794+ function printPathExpression ( node , print ) {
795+ if ( node . head . type === "AtHead" ) {
796+ return print ( "head" ) ;
797+ }
798+
799+ if ( node . tail . length === 0 && node . original . includes ( "/" ) ) {
795800 // check if node has data, or
796801 // check if node is a legacy path expression (and leave it alone)
797802 return node . original ;
0 commit comments