Re: 2 questions
> I've sent this email to Template-Toolkit mailing list... but there doesn't > seem to be anyone, so I'm sending it here ... Um, you did send it at 6:30PM on a Sunday (yesterday). Support on that list is really good, but you can't expect everyone to be on the same schedule as you. > How can in the parent template distinguish between these two cases (if > scalar place it, if file include it ). You could handle this with a plugin. The plugin would determine what kind of thing $stuff is, and then call the appropriate TT methods to handle it. In your template you say something like: [% MY_INCLUDE $stuff %] > I need a way to replace the web-designer > inputs,select boxes, textareas with thouse generated from me, but also want > to preserve the formating/styles etc.. f.e. There are basically two ways people do this. One is to replace the standard HTML elements with your own, e.g. becomes [% form.select(size => 10, name => "foo") %]. The other is to post-process the resulting HTML with something like HTML::FillInForm. That could be done inside a FILTER block. If the first appeals to you more, but you don't want your designers to have to think about it, you could pre-process the templates to translate the form elements to TT syntax. There's plenty of documentation for this module that covers the details of plugins and filters. - Perrin
Re: 2 questions
ivan <[EMAIL PROTECTED]> said something to this effect on 07/09/2001: > ok I have two questions about TT, let me begin with the > first one the easier ... *snip* > How can in the parent template distinguish between these two > cases (if scalar place it, if file include it ). There is > third case what if it is scalar-template -> then we have to > parse/process the scalar.. The parent template cannot distinguish between these cases, nor should it. The mechanisms for INCLUDING files and echoing strings are radically different because of how the grammer is written. Take a look at the Template::Context::include method to see how and where you can override the behavior of INCLUDE by subclassing Template::Context. (darren) -- Nothing worse could happen to one than to be completely understood. -- Carl Gustav Jung
2 questions
hi, I've sent this email to Template-Toolkit mailing list... but there doesn't seem to be anyone, so I'm sending it here ... Could anyone help me out with these ok I have two questions about TT, let me begin with the first one the easier ... I have the folowing situations I have a template like this $vars = { stuff => 'filename.tpl' }; then in the parent template [% INCLUDE $stuff %] Ok the problem is that sometimes I generate the contens on the fly so I can have in $stuff not the file name, but the content itself i.e. $vars = { stuff => 'blah' } i.e. I need [% $stuff %] not [% INCLUDE $stuff %] How can in the parent template distinguish between these two cases (if scalar place it, if file include it ). There is third case what if it is scalar-template -> then we have to parse/process the scalar.. Now the SECOND question : This is mostly related to FORMS ( i've done one module that generate for me forms content, insert/update queries, filled forms from a common config file), so what I need ... I need a way to replace the web-designer inputs,select boxes, textareas with thouse generated from me, but also want to preserve the formating/styles etc.. f.e. Designer wrote (the idea is ): ... ... ... I have to remove & but preserve the "size", "style" and "class" -> replace name with "name" created by me -> and extract input-type for further usage in my script... Also I'm populating the SELECT-options from the DB so I must replace the designers-made with mine. it has to be some sort of callback function that will be called every time the TT hit some form-element... I thought of several variants with using WRAPPER, BLOCK.. !?! which doesn't help me alot possibly this has to be some sort of FILTER ?! has to have the ability to get arguments !?!? May be : [%FILTER parse(tplname=myslect, size=10, style="...")%] ... ... ... [%END%] [%FILTER parse(tplname=myin, size=12, class=blah)%] [%END%] Please help me... i haven't written a filter !?! is there any other solution !?!? Thanx alot = iVAN [EMAIL PROTECTED] =