Closed a2exfr closed 7 years ago
How do subkeys work? Can you give me an example? I just don't get it :)
For example in section values we have array
'button_link' => array("url"=>'some link', "prefix"=> "some prefix", "title"=>"12345")
;
now in section[content] we echo it in this way:
<a href="{{button_link|url}}">{{button_link|title}}</a>
this is first simple approach for one level arrays
subkey is just a word)
I don't believe we need more than 1-dimensional arrays. Very cool!
Now we only need a conditional rendering.
Maybe sth. like
{{if[[show_elements}}<div>ELEMENT 1</div>{{show_elements]]if}}
{{else[[show_elements}}<div>ELEMENT 2</div>{{show_elements]]else}}
Is there a common standard for such stuff? I haven't used templating any languages lately O_o
Espression Engine uses
{if age == 30}
You are 30!
{if:elseif username == 'Bob'}
You are Bob!
{if:else}
You're not 30 or Bob. That's all we know.
{/if}
Smarty goes a similar route with
{if $name eq 'Fred'}
Welcome Sir.
{elseif $name eq 'Wilma'}
Welcome Ma'am.
{else}
Welcome, whatever you are.
{/if}
We certainly will not implement a complete template engine here, but we also shouldn't alienate TE users by doing common things in an unusual manner. Maybe...
{if{show_elements}}<div>ELEMENT 1</div>{{show_elements}if}
{else{show_elements}}<div>ELEMENT 2</div>{{show_elements}else}
Template engine is too much... of cause this things {{val}}
is really unflexible.
If think we should leave conditions as is and not invent a bicycle. And if really necessary use $section[values]
Because, we need not only conditions, but foreach loop for upcoming multi image field(is actually ready,I try to push it in evening)
Of cause, we can do simple foreach syntax like {{value|%}}
. Ok, now we need to echo each image in div or li. Let's do for example {{value|%|<li>|</li>}}
not pretty but can be.
And what to do, if suddenly we need add class to first of li ?)
Agreed. Although a basic boolen condition based on a value that is (or evaluates to) true|false, we could support {{if:value}}
one level array elements echo syntax {{array|key}}