benchpressjs
Advanced tools
Changelog
Version 2.2.0 (2020-11-15)
This release includes a rewrite of the compiler, using the parser combinator library nom
.
This rewrite has drastically improved code quality and extensibility. As part of the rewrite, structures include information about source location, so warnings now display file (assuming file name was passed to precompile
), line, and column.
Also a performance win: the new compiler is about 4.4 times as fast.
The following features are deprecated, to become errors in v3.0.0:
You may see a warning like the following:
[benchpress] warning: keyword outside an interpolation token is deprecated
--> tests/templates/source/loop-tokens-conditional.tpl:4:65
|
4 | <!-- IF @value --> → <span class="label label-default">@value</span><!-- ENDIF @value -->
| ^^^^^^ help: wrap this in curly braces: `{@value}`
| note: This will become an error in the v3.0.0
This is a legacy of backwards compatibility with templates.js, where this was supported for @key
, @value
, and @index
.
You may see a warning like the following:
[benchpress] warning: mixing token types is deprecated
--> tests/templates/source/mixed-syntax.tpl:20:1
|
20 | {{{if rooms.length}}}
| ^^^^^^^^^^^^^^^^^^^^^ `if` started with modern syntax
::: tests/templates/source/mixed-syntax.tpl:34:1
|
34 | <!-- ENDIF rooms.length -->
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ but legacy syntax used for `ENDIF`
| note: Migrate all to modern syntax. This will become an error in v3.0.0
We added some new warnings to help you avoid common issues:
[benchpress] warning: output bloat due to ambiguous inner BEGIN
--> tests/templates/source/nested-loop.tpl:1:37
|
1 | <!-- BEGIN animals -->{animals.name}<!-- BEGIN hobbies -->{animals.hobbies.name}<!-- END hobbies --><!-- END animals -->
| ^^^^^^^^^^^^^^^^^^^^^^ `hobbies` could refer to the top-level value `hobbies` or
the `.hobbies` property of the current element, so compiler must emit code for both cases
| note: Migrate to modern syntax to avoid the ambiguity. This will become an error in the future.
This exists to support backwards compatibility with templates.js, which supported this behavior. Switching to modern syntax will allow you to avoid this ambiguity, resulting in faster templates (and faster compiles).
This warning isn't actually new, just improved.
[benchpress] warning: found extra tokens
--> tests/templates/source/extra-tokens.tpl:17:7
|
17 | </div><!-- END container -->
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove the token or make it an unambiguous comment
--> tests/templates/source/extra-tokens.tpl:25:64
|
25 | <p class="list-group-item-text">{rooms.description}</p><!-- END description -->
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the token or make it an unambiguous comment
--> tests/templates/source/extra-tokens.tpl:32:66
|
32 | <p class="list-group-item-text">Click here to create one!</p><!-- END -->
| ^^^^^^^^^^^^ help: remove the token or make it an unambiguous comment
= note: These tokens will be passed through as text, but this will become an error in the future.
Another legacy of backwards compatibility with templates.js, which would ignore these cases due to how it worked.
Changelog
Version 2.1.0 (2020-11-08)
.parse
and .compileParse
Changelog
Version 2.0.9 (2020-11-07)
Changelog
Version 2.0.8 (2020-10-14)
Changelog
Version 2.0.6 (2020-10-08)
Changelog
Version 2.0.4 (2020-09-13)
Changelog
Version 2.0.3 (2020-05-09)