Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
None of the surveys I've seen look at Petal which is based on Zope's TAL/ZPT. As far as I'm concerned there is no other way to do HTML/XML templates.


Welcome back <b tal:content="user/name">Sample Username</b>, you last logged in <i tal:content="user/last_login">Sat 23rd Aug</i>

When you look at this in dreamweaver or a browser you'll see

Welcome back Sample Username, you last logged in Sat 23rd Aug

(view source on this page and you'll see that I have simply pasted in the code)

When you run this through the Petal engine you pass in a hash of data, say $h. Assuming

$h = { user => { name => "Fergal Daly" last_login => "Feb 22nd" } }
The processed output will be

Welcome back Fergal Daly, you last logged in Feb 22nd

As you can see, the HTML beforehand is well formed, includes sample values for the dynamic parts and all you have to do with Dream weaver is apply styles to the sample data and all will be well. At template compile time, all the sample data is discarded and then at run time, the real data is inserted.

Of course TAL handles loops and conditionals etc. The thing that takes the most getting used to is that it's a little verbose. Unfortunately this is a necessary side effect of being truly compatible with XML/HTML.

In reply to Re: Survey of Surveys on HTML Templating systems by fergal
in thread Survey of Surveys on HTML Templating systems by tphyahoo

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (5)
    As of 2021-04-19 13:43 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found