I have a question about a template rendering process and how to do it.
Imagine i have main.html and on this template i have a for loop to cycle things.
- Code: Select all
some content
{% for genericArray as element %}
{{ GENERIC }}
{% endfor %}
other content
Now, imagine i have 20 components classes that must cycle their arrays but i just want to be able to use ONE design of the cycle and inside the cycle i should be able to customize the element rendering. This way when designer changes main.html will change everything!
Note that, each component must be able to define how a element is rendered! This is important!
Let me try to explain what i want to archieve with and example (that do not works but explains my goal)
Imagine component A:
- Code: Select all
$data = $this->....();
$this->view()->assign( 'GENERIC', '<strong>{{element.id}}</strong>' );
$this->view()->render( 'main', $data );
will be rendered as:
- Code: Select all
some content
{% for genericArray as element %}
<strong>{{element.id}}</strong>
{% endfor %}
other content
so will output:
- Code: Select all
some content
<strong>1</strong>
<strong>2</strong>
other content
Imagine component B:
- Code: Select all
$data = $this->....();
$this->view()->assign( 'GENERIC', '<a href="{{element.url}}" />' );
$this->view()->render( 'main', $data );
will be rendered as:
- Code: Select all
some content
{% for genericArray as element %}
<a href="{{element.url}}" />
{% endfor %}
other content
will output:
- Code: Select all
some content
<a href="http://...../a/" />
<a href="http://...../b/" />
other content
How can i do it? Maybe with a new DooViewBasic method?
Francisco A

