Files
handlebars.js/spec
Robert Jackson 62ed3c25c7 Add Handlebars.parseWithoutProcessing (#1584)
When authoring tooling that parses Handlebars files and emits Handlebars
files, you often want to preserve the **exact** formatting of the input.
The changes in this commit add a new method to the `Handlebars`
namespace: `parseWithoutProcessing`. Unlike, `Handlebars.parse` (which
will mutate the parsed AST to apply whitespace control) this method will
parse the template and return it directly (**without** processing
😉).

For example, parsing the following template:

```hbs
 {{#foo}}
   {{~bar~}} {{baz~}}
 {{/foo}}
```

Using `Handlebars.parse`, the AST returned would have truncated the
following whitespace:

* The whitespace prior to the `{{#foo}}`
* The newline following `{{#foo}}`
* The leading whitespace before `{{~bar~}}`
* The whitespace between `{{~bar~}}` and `{{baz~}}`
* The newline after `{{baz~}}`
* The whitespace prior to the `{{/foo}}`

When `Handlebars.parse` is used from  `Handlebars.precompile` or
`Handlebars.compile`, this whitespace stripping is **very** important
(these behaviors are intentional, and generally lead to better rendered
output).

When the same template is parsed with
`Handlebars.parseWithoutProcessing` none of those modifications to the
AST are made. This enables "codemod tooling" (e.g. `prettier` and
`ember-template-recast`) to preserve the **exact** initial formatting.
Prior to these changes, those tools would have to _manually_ reconstruct
the whitespace that is lost prior to emitting source.
2019-10-28 00:28:28 +01:00
..
2014-11-08 14:35:23 -06:00
2018-09-04 00:15:02 +02:00
2019-09-24 07:31:19 +02:00
2015-08-03 23:43:00 -05:00
2015-09-01 17:56:32 -05:00
2015-08-22 10:59:34 -07:00
2015-04-16 16:43:01 -05:00
2015-09-23 21:59:58 -05:00
2015-09-01 17:56:32 -05:00
2017-10-21 15:42:27 +02:00
2015-04-16 16:43:01 -05:00
2015-04-16 16:43:01 -05:00
2017-10-21 15:42:27 +02:00
2015-04-16 16:43:01 -05:00
2015-04-16 16:43:01 -05:00
2015-08-03 12:16:02 -05:00
2015-09-01 01:44:35 -05:00
2015-08-22 10:59:34 -07:00
2015-04-16 16:43:01 -05:00