Heya,

I've thus caught the Test::More and Co bug and find myself wanting to  
add tests to almost every part of my proggy.

One part of the proggy that I'd love to test are my template files.  
It seems of good value to test the structure of the templates, as  
user contributions from people who may not be quite familiar with the  
templates, but still want to add something, may introduce new  
formatting bugs.  I'm hoping there's a already existing strategy for  
doing this. I've tried something like this test:



#!/usr/bin/perl

use Test::HTML::Lint tests => 1;

my $html = q{
     <table>
     <!-- tmpl_loop foo -->
      <tr <!-- tmpl_if __odd__ -->style="background-color:#ccf;"<!--/ 
tmpl_if-->>
       <td>
        Something.
       </td>
     </tr>
     <!--/tmpl_loop-->
     </table>


};

html_ok($html, "We're good.");



Which, when run, returns something like:


Justins-Computer:/t justin$ perl HTML_Template_test.t
1..1
not ok 1 - We're good.
#   Failed test 'We're good.'
#   in HTML_Template_test.t at line 19.
# Errors: We're good.
#  (8:5) </tr> with no opening <tr>
# Looks like you failed 1 test of 1.


Removing the, "<!-- tmpl_if __odd__ -->style="background- 
color:#ccf;"<!--/tmpl_if-->" from the HTML snippet seems to make the  
test pass.



Obviously, this isn't a bug in HTML::Template, if anything, it's a  
bug in HTML::Lint  - although I'll have to see if HTML comments are  
valid markup inside other HTML tags. Even if they are, the test is  
returning an incorrect error. HTML::Lint hasn't been updated in a  
while and has a few open bugs, so I don't know if this is the best  
solution to my needs.

Just passing the template to HTML::Template will tell me if the  
template is accepted and there's no problems with the <tmpl_*> tags,  
but it's not going to tell me anything about the rest of the HTML.

Does anyone else have a better strategy for testing the structure of  
their HTML::Template templates? I'm wondering what the potential of  
the block tags making the template itself have inconsistent HTML  
structure. Probably fairly great, although it may be an interesting  
thing to enforce; (most) any template could be included without  
problem in (most) any other template.


Justin Simoni
-- 
:: is an eccentric artist, living and working in Denver, Colorado
:: URL: http://justinsimoni.com
:: Mailing List - http://justinsimoni.com/mailing_list.html



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to