PATCH: namespaces + special variables
| From: | Hans-Peter Oeri | Date: | Fri, 12 Oct 2001 08:48:22 +0000 |
| Subject: | PATCH: namespaces + special variables | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-1678@lists.php.net to get a copy of this message | ||
Hi!
Attached patch includes my prior suggestion (see there for description)
plus some new features:
a) special variables
"special" variables like $smarty may now be defined in the attribute
var_special (the old $smarty being the default, only added a "global"
space). The values don't get really assigned anymore, but the respective
code snippet is included directly in the compiled template.
old:
a) assignment of HTTP_GET_VARS to _tpl_vars['smarty']['get']
b) inclusion of _tpl_vars in the compiled template
new:
a) inclusion of HTTP_GET_VARS in the compiled template
Of couse, I may define whatever special variable I want with whatever
nesting level of additional parameters. In the example, I define "$global"
as special variable, referring to global space
In the translation string, there are parameters recongnized:
%1 = first index to variable after "special" part
%2 = second
[...]
%D = all index parts, concatenated as with normal variables
%d = all not previously referenced index parts, concatenated
%A = array of all index parts
%a = array of all not previously referenced index parts
b) special prefix
Special prefixes, having a "namespace" beginning with "->", recursively
replaced with the remainder of the namespace. In the example, I define the
variable prefix "^" to reference global variables:
^var -> $smarty.global.var
$smarty.global.var -> $GLOBALS['var']
DISCLAIMER:
As usual, I don't guarantee for nothing. There are surely still errors in
it.
I wonder if no one is interested in at least commenting my efforts?! Or
are my suggestions that silly? However, I keep trying, even if I'm the
only one using it.
Don't conform!
IkKampfCaspar75