View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Sep 15, 2004 4:56 pm Post subject: |
|
|
%% was deprecated to keep the template syntax simple, thus keep compiling simple. It may get removed altogether at some point. I'm not adverse to using $_ though, that doesn't add a new var syntax. It also has the variable naming convention of a "private" variable, which makes sense in this case.
I'm still not fond of requiring a new parameter on the section function, internal var references should be automatic and consistant. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Sep 15, 2004 5:56 pm Post subject: |
|
|
Okay.
Just to add another idea: maybe we could add a switch/option using a new class member variable to decide if we should automatically create internal private vars for various structures. Perhaps $auto_private_var = true or even $auto_private_var_prefix="_". In the latter case, if null or empty, then use don't auto create vars others prefix the name with the given text. For example, I might choose $auto_private_var_prefix="this_" and in template:
{section name="foo" loop=$bar}
{$this_foo.index}
I guess I would just like to avoid any assumptions on Smarty's part in terms of the namespace. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Sep 15, 2004 6:18 pm Post subject: |
|
|
no more config-options please. and especially no config-options that affect template-syntax or semantics.
if you want a shortcut to your section-properties, I'd call it assign:
{section name=foo assign=foo loop=3}{$foo.index}{/section}
(maybe we could make the name optional in that case)
the same would work for {foreach} then.
a case of precedence is {capture}:
{capture name=foo}...{/capture}{$smarty.capture.foo}
was there, and
{capture assign=foo}...{/capture}{$foo}
was added later for convience.
i think this is a little comparable to what you have in mind with section. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Sep 15, 2004 6:24 pm Post subject: |
|
|
messju wrote: | no more config-options please. and especially no config-options that affect template-syntax or semantics. |
Why? Its not the same as a PHP config since it is completely with the user's control.
Never-the-less, I somewhat agree with your reasoning. Its just that "assign" doesn't seem to make as much sense here as it does in something like capture. Still, it is probably the best suggestion yet. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Sep 15, 2004 7:14 pm Post subject: |
|
|
messju wrote: | if you want a shortcut to your section-properties, I'd call it assign. |
"assign" makes me think the output of the section loop gets assigned to the variable, which would be a good assumption if the use of assign was consistant (which would be desirable?)
So, I vote for either introducing $_, or just drop it altogether and continue to use the already available $smarty.* variables. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Sep 15, 2004 7:54 pm Post subject: |
|
|
[quote="mohrt"] messju wrote: | So, I vote for either introducing $_, or just drop it altogether and continue to use the already available $smarty.* variables. |
my vote goes for the latter of the two above |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Sep 15, 2004 8:40 pm Post subject: |
|
|
Alas. Well, then not using "name" but rather using "alias" or "this" or one of the other suggestions seems appropriate to me. I'm willing to let it go, though....
But riddle me this: why isn't $_smarty_vars pre-populated with the appropriate keys to act as placeholders for the various values it can hold?Something along the lines of:
$_smarty_vars = array('section'=>array(), 'foreach'=>array(), ....);
The reason I ask is because without that little detail I think it makes my alias plugin idea kinda moot since I can't bind to an element that doesn't exist. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Sep 23, 2004 12:46 am Post subject: |
|
|
For me, the worst thing about section is the way that the name property is used in-template. I find the following (standard!) syntax very non-intuitive and not inline with variable handling everywhere else in Smarty:
Code: | {section name=tr loop=Links}
{$Links[tr]}
{/section}
|
I think it would be more obvious if that were:
My point is that it is more than just getting a short-cut to $smarty.section.varname -- there is an opportunity to clean-up the syntax (@monte: I'm -1 for introducing new syntax quirks on this one). I would even go far as to say to hell with BC and propose what I think is most obvious (and also the main thrust of this thread so far )
Code: | {$Links[$tr.index]} |
No new attributes, no pretending to try to accomodate every old template. On the other hand, I would leave the existing syntax but I would propose that it be deprecated. |
|
Back to top |
|
tibuda Smarty n00b
Joined: 15 Apr 2007 Posts: 1
|
Posted: Sun Apr 15, 2007 10:45 pm Post subject: |
|
|
Quote: | Posted: Wed Sep 22, 2004 9:46 pm |
Sorry for the necroposting, but I wish to know if this is already implemented. |
|
Back to top |
|
|