Braces.Handlebars.parse/2 is a port of Handlebars.js's handlebars-parser (2.2.4, commit c3c048f). It gives Braces.Handlebars.AST structs, the same AST as handlebars-parser, with each node's loc (line from 1, column from 0, in UTF-16 code units as Handlebars.js counts them).

{:ok, ast} = Braces.Handlebars.parse("Hi {{name}}")
ast.body
#=> [%Braces.Handlebars.AST.ContentStatement{value: "Hi ", …}, %Braces.Handlebars.AST.MustacheStatement{…}]

Parse errors

A template that doesn't parse is a Braces.Handlebars.ParseError. Its description is Handlebars.js's message, and its message adds the template's line with a caret under the error, as does the CompileError from ~HBS:

if doesn't match each - 1:3

    {{#if a}}{{/each}}
       ^

A syntax error has its own description instead, on the line Handlebars.js reports, with the caret at the start of the tag that doesn't parse, even inside blocks (Handlebars.js points at the token inside the tag). That includes an {{else}}, {{^}} or {{else if}} its block can't have, and a {{!-- comment with no --}}. When a block closes with another block's name, or has an invalid path, before the syntax error, that error is reported instead, as Handlebars.js does. The caret counts a wide character, such as an emoji or a CJK character, as two columns:

Parse error on line 3, column 2: unexpected "{{foo bar=}}\n{{/each"

      {{foo bar=}}
      ^