in reply to Can a Template file be an HTML file?

The filename extension usually gives you a broad idea of the contents, so I wouldn't go for it. In a remote future (1 month) you could be happy to remember that your template stuff was in those weirded-named files ending in tmpl, and be able to separate it from the plain html. Moreover, I'd keep those files outside the directory tree exposed by the web browser, because someone could access those pages directly. So, these pages aren't strictly HTML (at least in their semantic) and aren't to be served by the webserver directly - why would you call them html?

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: Can a Template file be an HTML file?
by Tanktalus (Canon) on Jun 14, 2005 at 14:27 UTC

    Actually, my advice is the opposite. Put your templates in a template directory, and then keep the .html suffix. Then, when I load the file in most html editors, they recognise it immediately from the suffix. They don't quite "get" the tmpl_ tags, but I can highlight things and mark them "strong" or "em"phasis or "div" or whatever. (For some reason, I don't think my editor allows blink. Oh well :-})

    This way, I get all the shortcuts for adding tags, I get the syntax highlighting, and I know they're templates from the directory they're in.

    I actually started with your advice: new name, outside directory. I went back on the name because I found I was always telling my editor to pretend that .tmpl was actually HTML, so I cheated by putting them in files that the editor understood were HTML.

    And I'm even more glad I did now - I have another templating system based on Text::ScriptTemplate that I use at work where .tmpl is now taken for that - and having my editor autoload .tmpl as HTML would make those look very, very silly. (No, that's not used for webpages, but for almost anything else - including shell scripts.)

      The syntax-highlighting hint seems quite good indeed, and as long as one is able to quickly understand which kind of files s?he's dealing with you're perfectly correct (BTW, even a find would remain useful). OTOH, one can use different filename suffixes for different purposes, so you could easily associate .tmpl to HTML highlighting, and say .stpl to the other templating system - but it really becomes a matter of pure personal taste at this point.

      Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

      Don't fool yourself.