Re: [SMARTY] defining arrays in config files

From: Date: Tue, 24 Feb 2004 12:42:01 +0000
Subject: Re: [SMARTY] defining arrays in config files
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11016@lists.php.net to get a copy of this message
Think YAML and XML are slightly off topic Indeed XML could be used instead of config files, however that would make is more dificult from us humanoids to edit. One thing I will say is that I use Config files to store different languages Tikiwiki for example which uses smarty has a tra("string to translate") function - however the lang files are in php the solution envisaged in wishful thinking is as follows almost psuedo code config file ........ months[jan] = "January" months[feb] = "February" months[mar] = "Ionawr" ... months[dec] = "December" login[username] = "User Name" login[err_name_not_found] = "Oeth dy enw dim gyda ni" and the template as follows.... <table><tr> {section name=mo loop=#months#} <td>{if $current_month == #months[mo]#}<b>{/if}#months[mo]#</td> {/section} </tr></table> #login.username# {if $err != ''} #login[$err] {/if} this is getting exiting Pete Tarik Ansari wrote:
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


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