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.

Beautify doesn't format HTML with Twig correctly

See original GitHub issue
  • Operating System (+Version): macOS 10.12.5
  • VS Code Version: 1.14.1
  • beautify Version: 1.1.1

Provide the settings you use: (VS Code workspace and user settings, .jsbeautifyrc, .editorconfig) eg.: VS Code:

"beautify.language": {
    "html": {
      "type": ["htm", "html", "twig"],
      "ext": ["twig"]
    }
  },

.jsbeautifyrc

{
  "html": {
	"indent_with_tabs": false,
	"max_preserve_newlines": 2,
	"preserve_newlines": true,
	"keep_array_indentation": true,
	"break_chained_methods": true,
	"wrap_line_length": 120,
	"end_with_newline": true,
	"brace_style": "collapse,preserve-inline",
	"unformatted": ["a", "abbr", "area", "audio", "b", "bdi", "bdo", "br", "button", "canvas", "cite", 
"code", "data",
		"datalist", "del", "dfn", "em", "embed", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "map",
		"mark", "math", "meter", "noscript", "object", "output", "progress", "q", "ruby", "s", "samp", "select", "small",
		"span", "strong", "sub", "sup", "template", "textarea", "time", "u", "var", "video", "wbr", "text", "acronym",
		"address", "big", "dt", "ins", "small", "strike", "tt", "pre", "h1", "h2", "h3", "h4", "h5", "h6"]
  },

Action performed

Format javascript file with HookyQR.beautifyFile command

Expected results

beautify is breaking the Twig code, it’s not formatted and indented correctly

Actual results

image

is there a way to ignore twig tags when formatting html documents including twig or a similar workaround? thanks a lot

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
leritcommented, Oct 20, 2017

i solve it by add settings in jsbeautifyrc file:

{
  "unformatted": []
}
2reactions
guillecrocommented, Oct 24, 2017

Ugh… sorry @HookyQR, I cannot make it work, not even adding the unformatted option So sorry cause I know how much work you’ve done for the extension 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code, format HTML code with Twig or Swig tags
To verify that everything's working properly, you can open the prettier terminal by clicking on Prettier at the bottom right in your VS...
Read more >
Using Prettier with Twig in VS Code - CodeKnight
I've been formatting code by hand in VSCode for months because the twig auto-formatting was completely broken. Here's how I got it working ......
Read more >
The First Prettier Plugin For Twig is Here - trivago tech blog
trivago open sourced a Prettier plugin for the Twig template language. It is available under the Apache 2.0 license, and you can access...
Read more >
The flexible, fast, and secure template engine for PHP - Twig
When extending Twig without creating an extension, Twig won't be able to recompile your templates when the PHP code is updated. To see...
Read more >
Code Formatting with Prettier in Visual Studio Code - YouTube
Formatting your code can be a hassle. Learn how to have your code automatically formatted to save yourself a lot of time 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