Thread: RE: [htmltmpl] ElseIF syntax...
Brought to you by:
samtregar
From: Gabriel F. <Gab...@is...> - 2002-11-20 10:09:10
|
Hi Simran... Bear in mind that doing this essentially defeats the main purpose of templates in general, and HTML::Template in particular, which is, namely, to separate logic from presentation. I've had situations where I've needed and elsif here and there, but it's best left in the code. When I want to handle displaying error messages, I have a generic template that displays status messages (not errors), so what you can do is this: Status: <TMPL_VAR NAME=STATUS> Message: <TMPL_VAR NAME=MESSAGE> And then you display an appropriate message. Based on if/elsif/else structures in your script. The nice thing about this is, you still only edit your code and your template stays the same, so you don't have to edit your code and template concurrently, thereby sticking to the edicts of using templates. Also, this method doesn't tie you down to using it for displaying only errors, you can use that one template to show all your status messages, be they errors or success messages. Sam, I'd like to take this opportunity just to say thanks once more for giving us all HTML::Template. TMTOWTDI :) HTH :) > I have a template where i really need to use "else if" conditions? How > do you all handle places where you need to use "else if"? > > A sample of my situation is: > > <tmpl_if name="error1"> > Error one occured > <tmpl_elseif name="error2"> > Error two occured > <tmpl_else> > No error could be determined... > </tmpl_if> > > If if was just two error messages, i could nest the if's but i have a > situation where i might have hundreds!!! "This e-mail may contain confidential information and may be legally privileged and is intended only for the person to whom it is addressed. If you are not the intended recipient, you are notified that you may not use, distribute or copy this document in any manner whatsoever. Kindly also notify the sender immediately by telephone, and delete the e-mail. When addressed to clients of the company from where this e-mail originates ("the sending company ") any opinion or advice contained in this e-mail is subject to the terms and conditions expressed in any applicable terms of business or client engagement letter . The sending company does not accept liability for any damage, loss or expense arising from this e-mail and/or from the accessing of any files attached to this e-mail." |
From: Cory T. <ct...@on...> - 2002-11-20 17:11:45
|
My thought: However, generating these messages in-code makes the component's interface far harder to internationalize, IMHO. However, in a situation where you have hundreds of error messages, in template errors would be very difficult to maintain. -- Cory > -----Original Message----- > From: htm...@li... > [mailto:htm...@li...]On Behalf Of > Gabriel Fortuna > Sent: Wednesday, November 20, 2002 5:06 AM > To: 'htm...@li...' > Subject: RE: [htmltmpl] ElseIF syntax... > > > Hi Simran... > > Bear in mind that doing this essentially defeats the main purpose of > templates in general, and HTML::Template in particular, which is, > namely, to > separate logic from presentation. I've had situations where I've > needed and > elsif here and there, but it's best left in the code. > > When I want to handle displaying error messages, I have a generic > template that displays status messages (not errors), so what you can do is > this: > > Status: <TMPL_VAR NAME=STATUS> > Message: <TMPL_VAR NAME=MESSAGE> > > And then you display an appropriate message. Based on if/elsif/else > structures in your script. The nice thing about this is, you > still only edit > your code and your template stays the same, so you don't have to edit your > code and template concurrently, thereby sticking to the edicts of using > templates. Also, this method doesn't tie you down to using it for > displaying > only errors, you can use that one template to show all your > status messages, > be they errors or success messages. > > Sam, I'd like to take this opportunity just to say thanks once more > for giving us all HTML::Template. > > TMTOWTDI :) HTH :) > > > I have a template where i really need to use "else if" conditions? How > > do you all handle places where you need to use "else if"? > > > > A sample of my situation is: > > > > <tmpl_if name="error1"> > > Error one occured > > <tmpl_elseif name="error2"> > > Error two occured > > <tmpl_else> > > No error could be determined... > > </tmpl_if> > > > > If if was just two error messages, i could nest the if's but i have a > > situation where i might have hundreds!!! > > > > > "This e-mail may contain confidential information and may be legally > privileged and is intended only for the person to whom it is addressed. If > you are not the intended recipient, you are notified that you may not use, > distribute or copy this document in any manner whatsoever. Kindly also > notify the sender immediately by telephone, and delete the e-mail. When > addressed to clients of the company from where this e-mail > originates ("the > sending company ") any opinion or advice contained in this e-mail > is subject > to the terms and conditions expressed in any applicable terms of > business or > client engagement letter . The sending company does not accept > liability for > any damage, loss or expense arising from this e-mail and/or from the > accessing of any files attached to this e-mail." > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: MArk W. <ma...@or...> - 2002-11-21 10:10:22
|
We have a system that is multi language and multi currency. We have a set of template paths that have the language as a directory so templates are picked up from .../templates/en/standard/templatename.tmpl. The en gives us the English version and the standard gives us the default customer as we allow some customers to customise thier screens. ALL the error messages are retrieved from a langauaged DB, so we can even have english templates with German error messages if we want. All of our cgi's 'know' what language they are and the path to follow for templates. It works very well, and still keeps code and template design/display separate. Mark Williams Cory Trese wrote: > My thought: > > However, generating these messages in-code makes the component's interface > far harder to internationalize, IMHO. > > However, in a situation where you have hundreds of error messages, in > template errors would be very difficult to maintain. > > -- Cory > > > >>-----Original Message----- >>From: htm...@li... >>[mailto:htm...@li...]On Behalf Of >>Gabriel Fortuna >>Sent: Wednesday, November 20, 2002 5:06 AM >>To: 'htm...@li...' >>Subject: RE: [htmltmpl] ElseIF syntax... >> >> >>Hi Simran... >> >> Bear in mind that doing this essentially defeats the main purpose of >>templates in general, and HTML::Template in particular, which is, >>namely, to >>separate logic from presentation. I've had situations where I've >>needed and >>elsif here and there, but it's best left in the code. >> >> When I want to handle displaying error messages, I have a generic >>template that displays status messages (not errors), so what you can do is >>this: >> >>Status: <TMPL_VAR NAME=STATUS> >>Message: <TMPL_VAR NAME=MESSAGE> >> >> And then you display an appropriate message. Based on if/elsif/else >>structures in your script. The nice thing about this is, you >>still only edit >>your code and your template stays the same, so you don't have to edit your >>code and template concurrently, thereby sticking to the edicts of using >>templates. Also, this method doesn't tie you down to using it for >>displaying >>only errors, you can use that one template to show all your >>status messages, >>be they errors or success messages. >> >> Sam, I'd like to take this opportunity just to say thanks once more >>for giving us all HTML::Template. >> >> TMTOWTDI :) HTH :) >> >> >>>I have a template where i really need to use "else if" conditions? How >>>do you all handle places where you need to use "else if"? >>> >>>A sample of my situation is: >>> >>> <tmpl_if name="error1"> >>> Error one occured >>> <tmpl_elseif name="error2"> >>> Error two occured >>> <tmpl_else> >>> No error could be determined... >>> </tmpl_if> >>> >>>If if was just two error messages, i could nest the if's but i have a >>>situation where i might have hundreds!!! >> >> >> >> >>"This e-mail may contain confidential information and may be legally >>privileged and is intended only for the person to whom it is addressed. If >>you are not the intended recipient, you are notified that you may not use, >>distribute or copy this document in any manner whatsoever. Kindly also >>notify the sender immediately by telephone, and delete the e-mail. When >>addressed to clients of the company from where this e-mail >>originates ("the >>sending company ") any opinion or advice contained in this e-mail >>is subject >>to the terms and conditions expressed in any applicable terms of >>business or >>client engagement letter . The sending company does not accept >>liability for >>any damage, loss or expense arising from this e-mail and/or from the >>accessing of any files attached to this e-mail." >> >> >>------------------------------------------------------- >>This sf.net email is sponsored by: To learn the basics of securing >>your web site with SSL, click here to get a FREE TRIAL of a Thawte >>Server Certificate: http://www.gothawte.com/rd524.html >>_______________________________________________ >>Html-template-users mailing list >>Htm...@li... >>https://lists.sourceforge.net/lists/listinfo/html-template-users > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |
From: simran <sim...@le...> - 2002-11-21 00:24:01
|
I think error messages can be very much a presentation issue... i have included a description of exactly what i am trying to do (hoping that people will have done similar or be able to shed some light from a different direction :-) Basic "Keep them in mind" issues ================================ * Internationalisation / Multi-lingual support * Simplicity and no programming logic What i have (only relating to the error template) ================================================= * I have one Error.tmpl template that is used by over 40 perl modules. For consistency's sake, i have used only one error template with a standard error loop structure. * Perl modules (for our software) can be written by various 3rd parties to an interface we specify (ie, they must inherit from our Base.pm module, implement some methods, and set errors via $self->setError(<error_code>, <error_string>); * The 'error_string' is usually an english error message such as "Could not verify email address sa...@so..." The error_code is a code (number/character combination) used in that module. * I wish to let programmers use any error_codes in their modules (they obviously are required to document them). * Now assume that a module sets an error with: $self->setError("CNLU22", "Could not load user $email") Usually i am happy with printing that as the error, but in one case i don't want to print the email address that is part of the error message (security reasons). The setError method sets the following template variable: * assume ref($self) = "MyModule"; * The template has the following set: $template->param("MyModule::ErrorCode::CNLU22" => 1); $template->param(errors => \@errors); Where errors is a templtae loop structure containing all errors! * The way we are using modules, there is a lot of inheritence going on and various modules might set errors along with way. For the moment, in my module, i just want to catch the error code's MyModule::ErrorCode::CNLU22, MyModule::ErrorCode::CNLU23 and MyModule::ErrorCode::CNLU24 - if the error is not one of those, then i am happy, just displaying the error_string set by the module. My question is - how can i do that in a template simply? <tmpl_if name="MyModule::ErrorCode::CNLU22"> Invalid user <tmpl_elseif name="MyModule::ErrorCode::CNLU23"> Invalid email <tmpl_elseif name="MyModule::ErrorCode::CNLU24"> Invalid password <tmpl_else> <tmpl_loop name=errors> <tmpl_var name=errormsg> </tmpl_loop> </tmpl_if> Given the above logic, how can i translate the above if/elseif/else stagements to just if/else statements? The above is a presentation issue to me as currently i am using the software just for the web, but say tomorrow i was using it for PDA's as well, then i might want to show error messages (based on codes) and associated help that make more sense to PDA users. simran. On Wed, 2002-11-20 at 21:05, Gabriel Fortuna wrote: > Hi Simran... > > Bear in mind that doing this essentially defeats the main purpose of > templates in general, and HTML::Template in particular, which is, namely, to > separate logic from presentation. I've had situations where I've needed and > elsif here and there, but it's best left in the code. > > When I want to handle displaying error messages, I have a generic > template that displays status messages (not errors), so what you can do is > this: > > Status: <TMPL_VAR NAME=STATUS> > Message: <TMPL_VAR NAME=MESSAGE> > > And then you display an appropriate message. Based on if/elsif/else > structures in your script. The nice thing about this is, you still only edit > your code and your template stays the same, so you don't have to edit your > code and template concurrently, thereby sticking to the edicts of using > templates. Also, this method doesn't tie you down to using it for displaying > only errors, you can use that one template to show all your status messages, > be they errors or success messages. > > Sam, I'd like to take this opportunity just to say thanks once more > for giving us all HTML::Template. > > TMTOWTDI :) HTH :) > > > I have a template where i really need to use "else if" conditions? How > > do you all handle places where you need to use "else if"? > > > > A sample of my situation is: > > > > <tmpl_if name="error1"> > > Error one occured > > <tmpl_elseif name="error2"> > > Error two occured > > <tmpl_else> > > No error could be determined... > > </tmpl_if> > > > > If if was just two error messages, i could nest the if's but i have a > > situation where i might have hundreds!!! > > > > > "This e-mail may contain confidential information and may be legally > privileged and is intended only for the person to whom it is addressed. If > you are not the intended recipient, you are notified that you may not use, > distribute or copy this document in any manner whatsoever. Kindly also > notify the sender immediately by telephone, and delete the e-mail. When > addressed to clients of the company from where this e-mail originates ("the > sending company ") any opinion or advice contained in this e-mail is subject > to the terms and conditions expressed in any applicable terms of business or > client engagement letter . The sending company does not accept liability for > any damage, loss or expense arising from this e-mail and/or from the > accessing of any files attached to this e-mail." > > > ------------------------------------------------------- > This sf.net email is sponsored by: To learn the basics of securing > your web site with SSL, click here to get a FREE TRIAL of a Thawte > Server Certificate: http://www.gothawte.com/rd524.html > _______________________________________________ > Html-template-users mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users > |