question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

html formatter doesn't support handlebars partial blocks (`#>`)

See original GitHub issue

Description

The handlebars support in the HTML beautifier is incomplete and doesn’t account for partial blocks. (as documented here: https://handlebarsjs.com/guide/partials.html#partial-blocks)

Input

The code looked like this before beautification:

{{#>row}}
    {{#>column}}
        <span>content</span>
    {{/column}}
{{/row}}

Expected Output

The code should have looked like this after beautification:

{{#>row}}
    {{#>column}}
        <span>content</span>
    {{/column}}
{{/row}}

Actual Output

The code actually looked like this after beautification:

{{#>row}}
    {{#>column}}
        <span>content</span>
        {{/column}}
        {{/row}}

Steps to Reproduce

Environment

OS: Windows 10 Pro VSCode version: 1.52.0

Settings

{
  "html.format.indentHandlebars": true,
  "html.format.enable": true,
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
a-ventocommented, Apr 13, 2022

I can work on this issue and will update you with any changes!

0reactions
bitwisemancommented, Dec 29, 2020

@Goobles
It is likely that the version inside vscode is out of date, so it is probably missing some fixes.

The space fixing the issue comes from here: https://github.com/beautify-web/js-beautify/blob/5bfad82226f98a5f6543fbde96e479e6763fd3cd/js/src/html/tokenizer.js#L71

The earlier code segment expects there to be two separate tokens for the start of the block the {{#> and the word following. So, we need some combination of fixes between the two.

I won’t have time to work on this any time soon, but PRs are welcome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code and Handlebars formatting unable to get partials on ...
From your example, it seems that you are using HTML Language Features as the formatter. Try setting this in your VS Code settings.json...
Read more >
Using Inline Partials and Decorators with Handlebars 4.0
Partials are a common templating concept not unique to Handlebars. The idea behind it is to create templates that are likely to be...
Read more >
Expressions | Handlebars
Handlebars expressions are the basic unit of a Handlebars template. You can use them alone in a {{mustache}} , pass them to a...
Read more >
Personalizing Templates with Handlebars
If the HTML-containing parameter comes from a data feed (and you have not merged ... Iterable message templates use Handlebars helpers and block...
Read more >
Handlebars
getHTML(), template = Y.Handlebars.compile(source), html; // Render the template to ... It doesn't support comparisons or logical operators like && and || ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found