Re: [SMARTY] defining arrays in config files
| From: | Tarik ANSARI | Date: | Mon, 23 Feb 2004 22:07:12 +0000 |
| Subject: | Re: [SMARTY] defining arrays in config files | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11014@lists.php.net to get a copy of this message | ||
> > > If that is not possible and BC must be broken, then I suggest
> > > a rethink and propose that syntax similar to YAML
> > > (http://yaml.org/spec/) be adopted.
> >
> > AFAIK yaml's goal is to be easily read and written by machines. in
> > contrast config-files should be maintained by humans.
>
> I'll try to stay on topic, but one of YAML's MAIN goals is to be easily
> readable (and producable) by humans (it is light on syntax). Many YAML
> documents look like "normal human" documents as opposed to machine
> readable instruction. True YAML has refined models for machine
> translation but that is natural since YAML does target serialization.
> Config files can of course be considered to be serialized data--indeed,
> that is Smarty's view of them. YAML is probably not appropriate at this
> juncture as syntax doesn't appear to be changing much, but it is worth
> considering for later adoption. If nothing else, it is worth reading
> the spec as the authors have covered the topic area very extensively
> and their ideas can be profitable when considering extensions to
> Smarty's config syntax, IMO.
To comply with YAML would need a huge refunding work over Smarty... I think
we better keep the current syntax and make it do what we needs for now and
we can plan then to improve it by a more logical language for after
(developpers following me, because i've got work to do on my project ;).
> One thing to consider with the syntax is the indexes. Ought things like
>
> foo.bar[1]
>
> be acceptable or should array indexes be handled automatically?
>
> eg:
>
> foo.bar[] (explicit) or even
> foo.bar (results in foo.bar[] as in current implementation for multiple
> foo.bar entries)
>
> This would preserve for loops on indexed arrays since they would be
> gauranteed to be sequential and without gaps. I would also suggest to
> go against the PHP convenience of allowing the mixing of indexed arrays
> and hashes.
Would say, let's do the easiest and let's PHP handle it. Let's add the
arrays feature as it work on templates. Then we can think about improve all
this.
> One last idea I had to throw out there: leave the section item
> processing exactly as it is (no dot notation) and instead make the
> section names be the thing that determine the array name:
>
> [foo.bar]
> ...
>
> [foo.baz]
> ...
>
> I guess this should be on the dev list. Oh well.
>
> xo boots
Thought about that, but I don't know if it's a good idea, we should restrict
ourselves to respect original template syntax if we wants to do a soft
transition and keep things easy for templates writters.
Tarik