Re: [SMARTY-DEV] syntax error: expecting '=' after attribute name
| From: | Monte Ohrt | Date: | Tue, 09 Dec 2003 18:05:35 +0000 |
| Subject: | Re: [SMARTY-DEV] syntax error: expecting '=' after attribute name | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1953@lists.php.net to get a copy of this message | ||
Straying from the template syntax rules only opens potential problems
for the future. That, and its certainly more difficult to tokenize.
A similar example, browsers have always allowed this kind of syntax:
<option name="foo" selected>
Then along came XHTML and claimed this is not valid, so
now we must make adjustments to be compliant:
<option name="foo" selected="selected" \>
So, let's not stray from the template syntax rules. All function
parameters must be in the form of var="val" for var=val. If you want to
write a prefilter that scans the template and appends an "=1" to your
missing values, by my guest. :-)
Monte
On Tue, 2003-12-09 at 11:13, Mark Rogers wrote:
> It is not currently possible to create a Smarty function as follows:
> {testfunc option}
>
> There are situations where it would be useful to allow single word
> parameters/options (eg "hidden"), which currently require instead
> {testfunc option=value}
>
> How trivial is it to change this so that if the =value is missing a value of
> TRUE is passed to the handler for that parameter, instead of generating an
> error? Ie, so that the following are equivalent:
> {testfunc option}
> {testfunc option=TRUE}
>
> It ought to be simple enough, but I just had a look at the tokeniser in
> Smarty_Compiler::_parse_attrs and got a bit lost :-(
>
> The specific use I had for this is a bit obscure, in that I'm trying to
> create a comment function which I can use to tempoarily skip certain parts
> of templates, eg:
> {include file="mytemplate.tpl"}
> becomes:
> {xx include file="mytemplate.tpl"}
> .. where xx simply does nothing; of-course this won't work because include
> then needs a value after it.
>
> But also consider situations where
> {checkbox name="test" value="testval" checked}
> is more readable than
> {checkbox name="test" value="testval" checked=1}
>
> --
> Mark Rogers,
> More Solutions Ltd