Help - Search - Members - Calendar
Full Version: Template comments revisited
Movable Type Community Forum > Other Product Discussion > Desired Features
BoredInsomniac
This has been mentioned before(sorry, but I don't remember if old threads with new comments float to the top) but I want to approach it from a different direction than Girlie took it before the thread quietly died.

What I would like, which Sherre mentioned, but as a secondary consideration, is a tag to comment within the templates themselves, not necessarily(though it would be a bonus) to hide template code from MT.
Using standard HTML comments seems like the obvious answer except that those comments will end up in the resulting HTML/PHP/whatever files, which makes absolutely no sense. It's a waste of bandwidth. Why would I want explanations of my templates to show up in my output files, which have no template code in them? MT code is becoming more complex as people figure out new things to do with it, not to mention that the addition of plugins with lots of entirely new tags is making it harder and harder to keep track of what you're doing. A true commenting tag that would be stripped before output would be really helpful as a development tool, and should(disclaimer: Perl looks like static to me) be easy to add, since it doesn't really *do* anything.
charle97
QUOTE
Using standard HTML comments seems like the obvious answer except that those comments will end up in the resulting HTML/PHP/whatever files, which makes absolutely no sense. It's a waste of bandwidth.


lol. that's hilarious.
BoredInsomniac
Well, that was insightful.
Care to speak to the matter at hand?
stepan
I've modified my MTTemplate plugin to add an MTTemplateComment tag which does what you are looking for.  One caveat is that the stuff inside the tag must be syntactically valid, as fat as MT is concerned (for example, the comment cannot contain <MTEntries> without the corresponding </MTEntries> tag).

This is how you would use it:
CODE
<MTTemplateComment>
Documentation that you do not want to be included
in documents generated from this template.
</MTTemplateComment>
bmk
charle97: you lost me.
charle97
i was commenting on how bored says using html comments to comment templates is a waste of bandwidth.  a few lines of comments doesn't really eat that much.  lots of white space in your html will eat up more bandwidth than comments.  if he's so concerned about bandwidth he should set up his templates to output his html in one continuous line.  that should reduce the file size.

processing load should be more of a concern than bandwidth. mt is going to spend additional time stripping out those template comments.
BoredInsomniac
It is a waste of bandwidth. This isn't the place to get deeply into this discussion, but the fact is that this is an aggregate consideration. With a very few exceptions, no single site has any marginally perceptible effect on the amount of traffic on the net. "A few lines of comments" spread out across every site active at any given time piles up really quickly. A few more lines of comments which are absolutely meaningless since they refer to something that the person viewing source can't see anyway, only adds to it. In the end, the point is that there's no reason whatsoever for a visitor to see comments referring to template code.
Yes, it's minutia, but I like my code clean and no larger than it absolutely has to be(standards differ). I actually do know people who do strip out all whitespace from their code before making it public, incidentally. I'd rather leave it legible for anyone wanting to look, not that I have any great contributions to make.
How is arguing the processing load of MT stripping out "a few lines of comments" valid(This is Perl, remember? It's fast), but not the load of sending unnecessary data across the net? It's not the issue anyway. Comments are a development tool. Anybody who would want/need this sort of thing would be willing to make the sacrifice for having the ability to document their templates. If you don't want it or don't care, then don't use it. Simple.

I can actually think of more obscure reasons for user-transparent commenting, but this is the most obviously practical.

Stepan: You rock. I'll take a peek at it later today.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.