RE: [SMARTY] Re: Making smarty tags xhtml compliant: prefilter

From: Date: Mon, 14 Oct 2002 15:02:36 +0000
Subject: RE: [SMARTY] Re: Making smarty tags xhtml compliant: prefilter
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6134@lists.php.net to get a copy of this message
Hi, Thanks for the response. "Now I think about a similar method to add namespaces (in fact it's more a namespace than a prefix) to smarty modifiers. The problem is that modiefiers take parameters separated with ":" which is also the namespace/tag delimiter :-(. What do you think how to implement this without modifying the parameter separator from ":" to "|" or something else for example?" After the prefilter is finished, the code must be parsable for Smarty. You may introduce another prefix / namespace type which will replace the formatting you require and deliver the temlate source that Smarty is fond of. "Smarty more XHTML compilant. Now I don't think this whould be the best solution anymore." The reason I prefer xhtml compliance is so that I can run the standard validators on the template code. I am not worried about color coding in my editor. Putting this in double quoted is a requirement of XML. "That would be no good idea because you cannot distinguish between vars and strings" I do not think this is a problem. "Now the template is a lot harder to understand because you cannot say which tag is interpreted by smarty and which one is pure html. {...} is simply easier to read and you can configure your favorite editor to highlight these smarty tags with a different color." I care to differ. Any tag that has the prefix / namespace format is to be interpreted by Smarty. Another reason is purely personal preference. I do not really facy tags starting and ending with curly braces, but I realize this is not a real argument. "Isn't this normal for XHMTL compilant code? "<" and ">" isn't allowed at all if itn't a tag delimiter." You are right, of cource. Regards, Martijn Original Message: ----------------- From: André Rabold arabold@nero.com Date: Mon, 14 Oct 2002 15:35:29 +0200 To: smarty-general@lists.php.net Subject: [SMARTY] Re: Making smarty tags xhtml compliant: prefilter Hi, I have added a similar functionality like your prefixes. I used the same functionality to replace "html:select_date" with "html_select_date" ;-) Now I think about a similar method to add namespaces (in fact it's more a namespace than a prefix) to smarty modifiers. The problem is that modiefiers take parameters separated with ":" which is also the namespace/tag delimiter :-( What do you think how to implement this without modifying the parameter separator from ":" to "|" or something else for example? This whould result in editing all existing templates and is no option I think. > have double quotes around them (e.g. <test att=$attvalue />. I would prefer > to be able to do <test att="$attvalue" />. That would be no good idea because you cannot distinguish between vars and strings anymore. There was a discussion at smarty wiki sites a few weeks ago about making Smarty more XHTML compilant. Now I don't think this whould be the best solution anymore. > <!@tagPrefix="smarty"> This is a very nice idea! I will code something similar into my own code ;-) > <form action="none"> > <html:select_date display_days="yes" /> <!-- will be converted to > {html_select_date } --> > <select name="gender" multiple="multiple" size="2"> > <form:options options=$gender_options selected=$testgender /> > </select> > <form:radio name="radio" options=$gender_options selected=$testgender /> > </form> > > </form> Now the template is a lot harder to understand because you cannot say which tag is interpreted by smarty and which one is pure html. {...} is simply easier to read and you can configure your favorite editor to highlight these smarty tags with a different color. > <test att="<b>bold text</b>" /> is not allowed. > however > <test att=$bold_text /> , where $bold_text has the value <b>bold text</b> > *IS* allowed. Isn't this normal for XHMTL compilant code? "<" and ">" isn't allowed at all if itn't a tag delimiter. "Martijn@Hooimeijer-It.Com" <martijn@hooimeijer-it.com> schrieb im Newsbeitrag news:68680-22002101141126152@M2W075.mail2web.com... Hello, I have been experimenting with smarty for about a month and I like it, except for the tag format with curly braces. I like the JSP custom tag better (where the tags are xml / xhtml compliant). I have been working on a prefilter which will allow the use of (almost) xhtml compliant Smarty tags. NB. It is not completely xhtml compliant, because in smart tags, attribute values that are smarty variables may not have double quotes around them (e.g. <test att=$attvalue />. I would prefer to be able to do <test att="$attvalue" />. Each tag is provided with a prefix which must be defined at the beginning of the template. There are two types of prefixes, (1) prefixes that are not added to the smarty tag name (e.g <smarty:literal> becomes {literal})(2) prefixes that ARE added to the smarty tag name (e.g. <html:select_date /> becomes {html_select_date }). For prefix type (1) use the code "tagPrefix", for prefix type (2) use tagPrefixAdd (see below for an example). The latter prefix type allows for a better classification of different plugins, so that a set of plugins can be grouped together by a simlilar prefix. This encourages cleaner template code (IMO). For an example see the use of a table tag family I am working on below. There are three plugins: - table_table - table_row - table_column which are grouped together using the "table" prefix. For this reason I have renamed some of the form plugins from html_* to form_* so that I can use all of the form plugins in a form context. For an an template example see below: ***** start sample code ******* <!@tagPrefix="smarty"> <!@tagPrefixAdd="table"> <!@tagPrefixAdd="form"> <!@tagPrefixAdd="html"> <html> <head> <title>{$title}</title> <smarty:literal> <!-- will be converted to {literal} --> <style> .col1 {background: blue;} .col2 {background: green;} .col3 {background: yellow; } </style> </smarty:literal> <!-- will be converted to {/literal} --> </head> <body> <form action="none"> <html:select_date display_days="yes" /> <!-- will be converted to {html_select_date } --> <select name="gender" multiple="multiple" size="2"> <form:options options=$gender_options selected=$testgender /> </select> <form:radio name="radio" options=$gender_options selected=$testgender /> </form> </form> <table:table border=1> <table:row class="test" valign="top" height="50" max_rows=$data.max_rows total_rows=$data.total_rows array=$personList > <table:column type="numbering" class="col1" placecontent="before" >No. </table:column> <table:column name="firstname" class="col2" header="First Name" sort="true"> </table:column> <table:column name="lastname" class="col3" header="Last Name" sort="true"> </table:column> </table:row> </table:table> </body> </html> ***** end sample code ******* There is one limition in the current plugin: attribute values may not have the value "<" in them. When the attribute value is a smarty variable, this limitation does not apply. e.g. <test att="<b>bold text</b>" /> is not allowed. however <test att=$bold_text /> , where $bold_text has the value <b>bold text</b> *IS* allowed. Greetings, Martijn -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ . -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ .

« previous php.smarty.general (#6134) next »