getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.62k stars 448 forks source link

Add comments on templates to show where the HTML is coming from #2985

Open ralsina opened 6 years ago

ralsina commented 6 years ago

For example, it happens that you are trying to edit a theme's index page.

You look at it and ... which template is generating that?

We could add comments in all templates and in blocks so that is explicit.

Sure, it makes the output larger, but if you are minifying html, the comments go away.

Kwpolska commented 6 years ago

Mako and Jinja have a comment feature. Those do not end up in the source output. We already use them in some places (in particular to specify the file encoding for Mako)

ralsina commented 6 years ago

Yeah, but I do want them in the output so people trying to make a theme know what template to tweak

Kwpolska commented 6 years ago

Then it gets a huge :-1: from me. This is completely irrelevant to most people and will look strange to people reading the source, unaware of what it means.

michaelb42 commented 6 years ago

In combination with a "draft" and "release" switch this would become really useful while editing themes, templates and changing styles. Applying some kind of "build configuration" to the filters, etc. one could easily choose between different tidy profiles and remove those comments in production builds, generate non-minified or minified css, etc. :+1:

michaelb42 commented 6 years ago

Hm, just recognized that nikola supports a --conf= option (is it documented somewhere?) that could be used to differentiate between a "draft" and a "release".

ralsina commented 6 years ago

Could be done as an option enabled/disabled by a switch.

Honestly, trying to do a theme without this is complicated. And I wrote the damned theme engine.