Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: autotie CGI::SSI to CGI::Application output

by ryan (Pilgrim)
on Feb 13, 2003 at 05:14 UTC ( [id://234905]=note: print w/replies, xml ) Need Help??


in reply to autotie CGI::SSI to CGI::Application output

OK, I'll have a go at my own question then :)

The reason for this is the HTML templates were rather 'pretty' and had a heap of nested tables in them that was just too much code to duplicate. So I wanted a way to call a function from within the template that can accept a parameter and produce the code for the table with the parameter as the title of the table.

In the end I found that HTML::Template::Expr can do this so I modified CGI::Application to use HTML::Template::Expr instead of HTML::Template and it all went well. It was just a simple substitution of the module name in two spots.

I know this is not a good use of templating technology, both I and the HTML::Template author agree there - but this particular case called for it.

The actual code in the CGI::Application module was a declaration of the template functions and their related subs:

HTML::Template::Expr->register_function(box => \&box); sub box { #read in other templates to costruct table header #use parameters to decide if it is the start or the #end of the box and what title to use etc. }
Then in the templates:
<!-- TMPL_VAR expr="box('box-start','Table title')" --> table contents here <!-- TMPL_VAR expr="box('box-end')" -->
Ugly, but it works and reduces the template code size to about half :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://234905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found