[htmltmpl] Writing an extension for HTML::Template - how to do it?
Hello folks! Don't know if it's just me or documentation of HTML::Template::Extension isn't good. Eitherway, I can't figure out how to write an extenstion for it, that I need for my project. I work with CGI::Application, and I wan't to be able to use (reusable) objects in my templates. For instance : My filter would find SomeName module (Prefix such as MyApp::Plugin::SomeName) make an instance of it and call method - say named run. And place returned value instead of this tag. Think of it as another template file that is included but it has some processing ... That way I can create one module/plugin and use it througth whole site/application. If I don't figure this out soon - I will have to give a shot to HTML::Template::Expr and register a function with it (). Thanks.
Re: [htmltmpl] Writing an extension for HTML::Template - how to do it?
Title: Message No need to send emails to both me and list (twice) I guess ? Anyway - I already looked into that. It's what CGI::Application::Framework uses. But it's not what I need/want. That way I can only call some run_mode (method) from current module (one that is outputing the template in the first place). I would need to manualy add plugins to each of the module (or just in base module). On the other hand, I could write an method in my base module (inherited by others). And implement that logic inside of him (require SomeModule, call some_run_mode in it ...). But all that would be similar like this: I was hopping to avoid that ... and make it shorter/simpler as: - Original Message - From: Dan Horne To: 'Webmaster Techcode.NET' ; [email protected] Sent: Tuesday, November 08, 2005 11:33 PM Subject: RE: [htmltmpl] Writing an extension for HTML::Template - how to do it? Hi Since you're using CGI::App, you should have a look at CGI::Application::Plugin::AnyTemplate - which will allow you to call a run mode with the H::T Dan -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Webmaster Techcode.NETSent: Wednesday, 9 November 2005 11:16To: [email protected]: [htmltmpl] Writing an extension for HTML::Template - how to do it? Hello folks! Don't know if it's just me or documentation of HTML::Template::Extension isn't good. Eitherway, I can't figure out how to write an extenstion for it, that I need for my project. I work with CGI::Application, and I wan't to be able to use (reusable) objects in my templates. For instance : My filter would find SomeName module (Prefix such as MyApp::Plugin::SomeName) make an instance of it and call method - say named run. And place returned value instead of this tag. Think of it as another template file that is included but it has some processing ... That way I can create one module/plugin and use it througth whole site/application. If I don't figure this out soon - I will have to give a shot to HTML::Template::Expr and register a function with it (). Thanks.
Re: [htmltmpl] Writing an extension for HTML::Template - how to do it?
Wouldn't it be great if everyone was writing docs like you do? :) I checked it out - it seems quite interesting. Will give it more thougth in the morning (it's 3AM ...). Thanks. Indeed, there are a number of solutions that can be implemented. HTML::Template::Expr with a function callback is probably the easiest solution.Another possiblility is to use the modified H::T that I use (available at http://members.optusnet.com.au/~mathew) to create your own TMPL_xxx syntax.Mathew
Re: [htmltmpl] loop through a hash structure without knowing the hash keys?
- Original Message -
From: Boon Chew
I want a way to quickly display all the info in a var - a Dumper output if you
will. But more than that, like in some other server-side language, you can
query the column lists (or hash keys) and loop through those and use a piece of
generic code when all you intend to do is to display everything in the var.
- Original Message -
I agree - something like Data::Dumper in HTML::Template context would be great.
And you can also "you can query the column lists (or hash keys) and loop
through those" in Perl just like in any other server-side language ...
foreach(@array){
print $_,"\n";
}
- Original Message -
The tight coupling of knowledge between what's being sent from the perl code
and the HTML can be avoided, that's the whole point of the design of the
template module (vs Mason where you mingle Perl code with display code) right?
It just seems ugly when I have to tell a designer to go look at the perl file
to see what he is getting in the var. He should be able to find that out fro m
some sensible constructs.
- Original Message -
You missed the point ...
I mean - designer shouldn't need to take a look at Perl code to figure out what
you are outputing ... And "some sensible constructs" are documents that folow
every project. Have you ever heared of terms like API or Interface? You and you
designer need to agree on "Interface" - in your case the data he can use in the
template ...
Anyway - the quick and simple solution that just crossed my mind ;)
Make something a rule - for each template - you could create a special
variable. Say you can name it : "the_dump" or whatever.
And simply dump via Data::Dumper all variables that you (plan) populate the
template with - or send to template.
Actualy - this could be made as part of HTML-Template ...
Anyway - then your designer could just add at the
end of the template if he is not sure what data he can access.
Of course - next thing he will complain is why in the hell he can't do a
preview in Dreamweaver with test data already populated ...
Cheers,
Alex.
N¬HYÞµéX¬²'²Þu¼¦[§Ü¨º
Þ¦Øk¢è!W¬~é®åzk¶C£ [EMAIL PROTECTED],º·âa{
å,àHòÔ4¨m¶ÿiÛ(±ÙÜ¢oÚv'
