🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

handlebars-error-parser

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

handlebars-error-parser

The purpose of this module is to parse the Handlebars compile exceptions messages into a more useable format which can be used in handlebars linter(s). Handlebars throws different exceptions depending the template error.

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

handlebars-error-parser

The purpose of this module is to parse the Handlebars compile exceptions messages into a more useable format which can be used in handlebars linter(s). Handlebars throws different exceptions depending the template error.

Handlebars exception types:

  • Parser Error: handlebars can't compile the template.
  • Block Error: the open and close block helpers do not match.

This module parses the exception message into:

{
    minLine: 1,
    minColumn: 3,
    maxLine: 1,
    maxColumn: 4,
    message: 'foo doesn\'t match bar'
}

Install

npm install handlebars-error-parser --save

In Node.js:

var parser = require('handlebars-error-parser').parser;
var html = '{{#foo}}{{/bar}}';
var parsed;
try {
    hbs.precompile(html);
} catch (e) {
    parsed = parser(e, html);
}

In browser:

<script src="./node_modules/handlebars-error-parser/index.js"></script>
var html = '{{#foo}}{{/bar}}';
var parsed;
try {
    hbs.precompile(html);
} catch (e) {
    parsed = window.HandlebarsErrorParser(e, html);
}

Block Error: Mismatched: block helpers

{{#foo}}{{/bar}}
foo doesn't match bar - 1:3

Block Error: Mismatached: closing helpler

{{foo}}{{/foo}}
Parse error on line 1:
{{foo}}{{/foo}}
-------^
Expecting 'EOF', got 'OPEN_ENDBLOCK'

Parse Error: Missing helper or variable closing

{{foo
Parse error on line 1:
{{foo
--^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'

Parse Error: Missing block helper closing

{{#foo
Parse error on line 1:
{{#foo
---^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'

FAQs

Package last updated on 18 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts