This could possibly go into SoPW, but it is more of a musing so here goes:

The problem I wish to address is content generated by Template from templates. I can envisage a situation where the perl code and the underlying templates are created and tested. Then in the future a web designer comes alnog and makes changes to the templates. Then the designer wants to check that they have not changed the functionality of the template in any way, which is a good thing. However they do not know Template beyond the very basics and know nothing of perl.

For example, how could a designer check that their modifications to the following are OK:

*** insert the introduction here *** [% FOREACH item = items %] id: [% item.id %] name: [% item.name %] quantity: [% item.quantity %] unit_price: [% item.unit_price FILTER format ( '%.2f' ) %] total_price: [% item.quantity * item.unit_price FILTER format ( '%.2f' + ) %] [% END %] ** insert thank you here ***
The template above could be easily processed and then tested against expected data (regression testing) to ensure that it works.

My proposed solution to this is that there should be two sets of templates: one is used to generate the content in production, the other is used to test that the production templates behave as expected. These two sets of templates would be identical in terms of their functionality.

During testing the two sets of templates are compared to see if they are functionally the same - hence the diff for templates. However it is not straight forward to write a script which strips out everything but the Template commands.

I have the following thoughts / questions:

I hope that this little musing of mine increases the ways to test, which for Templates currently appears to be quite few.

--tidiness is the memory loss of environmental mnemonics


In reply to Testing Template, or should I write a diff for TT templates? by EvdB

Title:
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, details, 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, summary, 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.