From: Myk Melez <[EMAIL PROTECTED]>

> [...]  The problem is that my
> documents then become just the stuff within the wrapper and aren't
> complete documents, making them harder to validate.  Also, it means all
> site contributors (and their HTML authoring tools) need to know TT at
> least well enough to set the page_title parameter, whereas now they just
> put the page title within the <title>  tag and the homegrown templating
> system picks it up.

I am using the same approach (valid HTML as input) with TT for some years
and find it very useful, especially for cooperation with contributors.

> But maybe all this doesn't matter.  Maybe validators do well enough with
> non-document snippets of HTML and the drawbacks to making everyone know
> TT are outweighed by the benefit of doing things the TT way (or there's
> a better way that resolves this conflict).  Thoughts?

I wouldn't want to rely on validators accepting invalid HTML :-)
I'd rather parse the sources myself (since they are valid, this
should be possible) and feed the results to TT.

I am using ttree, where I've written a small plugin around a HTML
parser (sadly not HTML::Parser - I need to cope with some "invalid"
HTML).  Everything is controlled by a template invoked by the
PROCESS option ('process' in a ttree config file), like that:

---------------------------------------------------------------------------
[% html_text = PROCESS ${template.name} # feed HTML source into variable %]
[% parsed = my_html_parser.parse(html_text) # extract title etc. to hash %]
[% import(parsed)  # so that defaulting can take place                   %]
[% DEFAULT ...     # set defaults for optional items in the source files %]
[% SET ...         # set the variables the templates needs for itself    %]
<html lang="[% language %]">
 <head>
   <title>[% title %]</title>
   <meta name="author" content="[% author %]">
...
 <body>
   ... navigation etc.
   [% content # from parsed.content, as provided by the parser %]
   ... footer
 </body>
</html>
---------------------------------------------------------------------------

I am using PROCESS in the first line because this allows "advanced
contributors" to control template behaviour from perfectly valid HTML
source files:

<html>
 <!-- [%
         style        = 'funky_tabular'
         author_email = '[EMAIL PROTECTED]'
      %] -->
 ...

With a little bit of documentation (and an example) most contributors
could use their favourite (validating) HTML editors to set TT variables.
--
Cheers,
haj





_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to