bminer / node-blade

Blade - HTML Template Compiler, inspired by Jade & Haml
Other
320 stars 28 forks source link

pretty html formatting #112

Closed larafale closed 7 years ago

larafale commented 11 years ago

hello there, is there anyway to display "pretty" output in express like Jade ?

app.locals.pretty = true

set a new line for each html tag with jade

bminer commented 11 years ago

Unfortunately, no. "pretty" HTML output is something that will probably not be implemented in Blade. The reasons for this are:

  1. Simplicity (the compiler would need to insert tabs/spaces into generated template code)
  2. Performance ("prettifying" HTML takes a bit more time and makes compiled templates larger)
  3. Many browsers already have debuggers/inspectors that you can use to sift through the DOM in a nice GUI. In other words, there is little need to "prettify" the HTML when using these tools
  4. Other 3rd party tools exist to prettify HTML (i.e. tidy)

As a workaround, take your Blade-generated HTML and run it through a tool like "tidy"

There is a tidy wrapper lib for Node.js: https://github.com/leondealmeida/node-tidy

Thoughts? I'm closing this issue for now...

braco commented 11 years ago

This is very important for debugging; HTML output can get pretty complex with nested partials in a large project. Sometimes one needs to debug on a platform without an inspection view immediately available, and sometimes you want to see HTML before Javascript has modified the source, as you would see by default in a console.

This should be a default in development environment when possible.

aficiomaquinas commented 11 years ago

This would be extremely useful for debugging. When trying to find errors, chrome dev tools says every error is on line 1...

bminer commented 11 years ago

This seems like a fairly popular request. I am curious... what is wrong with the proposed workaround (running the problematic HTML through a tool like tidy)?

aficiomaquinas commented 11 years ago

There is nothing wrong with it but it would be very nice if the language itself had it. It's like if sass only would output minified css, the developer needs different formatting and has to add all that middleware.

bminer commented 11 years ago

Alright, fair enough. I'll re-open this issue. I won't have time this year to work on it, but I will accept pull requests. :)

bminer commented 7 years ago

Closing this issue again, but I'd be happy to take PRs.