|Perl Monk, Perl Meditation|
RFC - Template::Emptyby redhotpenguin (Deacon)
|on Feb 25, 2008 at 08:13 UTC||Need Help??|
I'm tired of writing meta code in templating languages. I'm really good at writing Perl, and good at writing HTML, but I'm lousy at the templating languages (and I'm not too fired up to learn more about them).
I'm tired of form handling. I have written form handling modules, and they always get way too complicated. But then tonight I had an idea.
That idea is Template::Empty. If this sound crazy, just keep reading. It gets weirder.
HTML pages are easy to parse (please ignore server side includes for this rfc). The problem happens when you mix code and html in attempting to make them easy to write. Mixing code and html has done to many a programmer what mixing booze and pills has done to many a rockstar. The end result is never pretty.
So I introduce to you the concept of the empty template:
Note first off that the title tag is empty. So now we need a template object to fill that in:
There you have it. The class parses the html file once on load, and constructs a template object containing entities such as title which can be set, and form objects which can be manipulated. There are certainly libraries such as HTML::FillInForm, and Template, which can be used to implement the actual as_string() method which serializes the template output.
Of course, I'm sure this approach is fraught with its own nasty design issues, but it allows for a pure html template in some simple cases examined here. Feedback welcome.