http://qs321.pair.com?node_id=585388


in reply to Re: HTML::Template : How to separate code and html with lesser maintenance issues
in thread HTML::Template : How to separate code and html with lesser maintenance issues

I created some templates like

small_template.tmpl

<table align="center"> <tr><td align="center"> <font style="font-size: 14pt; font-family: Arial; solid #CCC; padding: + 3px" color="blue"> <p>Please Select an Item</p></font> </td></tr> </table>

and then read them into $html_output by

... ... open (FILE, "<", "small_template.tmpl" ); $html_output = join "", <FILE>; close FILE; ... ...

This works great but if I wanted to display some values of variables (like , the selected item's name ) using the small_template.tmpl, it doesn't work.

Probably, I should have some subrotines to create the html code and then display that using the template. I think it will mix the logic and the html, but it seems inevitable. The best I can do is to have subroutines that create the html messages separated from the logic.