Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

.. and I know this is a no-no here - much less as the first thing I post on PM. :)

However, there is a twist to this one.

Prelude

You see, I have evaluated all templating modules I could find, and I have seen all manner of interesting, cool, plain or otherwise approaches, but none of them satisfies me. It is amazing that will so many packages for doing templates out there, they all seem to fall into either of two extremes, with noone ever having walked the middle road.

The plot

They are either pure interpolators or (more or less) fullblown interpreters. Pure interpolators are modules like CGI::FastTemplate which will intentionally do absolutely nothing other than substitute variable names for values. Interpreters are modules like HTML::Template, TemplateToolkit2, HTML::Mason, AxKit and You::Name::It which will let you create templates that look more like some code source than HTML.

Mounting tension

Now I have a problem with both. Interpolators lead to a proliferation of microscopic tiny snippet templatelets whenever you try to produce tables, esp if there are different types of rows of which one gets chosen depending on some of the variables, or tables are nested, or (the Camel help me) a mix of both. Interpreters do solve this problem - but intersparsed with commands in arbitrary places and using visually complex constructs for the simple task of variable interpolation, their templates become a chore to read, much less write, not to mention that beyond a certain degree of complexity and flexibility (such as may be tempting to use with TemplateToolkit2) they go way above webdesigners' heads, putting the programmer back in the position of layout maintainer.

Climax

So what I am almost about to write is something that lies inbetween: CGI::FastTemplate-like syntax for interpolation, and SSI-like syntax for higher level constructs. On CPAN, there is nothing that meets these criteria. The Big Question is - does anyone know of an already ongoing effort for this kind of module?

Aftermath

If not, then here's a sneak peek at my overall idea: there will only be a single highlevel construct, a loop command that doubles as a conditional construct. Nested data structure interpolation will be supported by a dot operator ( "$[foo.bar]" = $templatevars->{foo}->{bar} ), with variables usable as part of variable names ( "$[foo.$bar]" = $templatevars->{foo}->{$templatevars->{bar}} - needs some thought about how exactly to disambiguate "$[foo.$bar.$baz]"). Comments?


In reply to I am about to write my very own templating module.. by Aristotle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-25 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found