views:

11

answers:

1

Hello there,

I got a phptal template question, I have an associative array which contains HTML attribute information, eg

attrs['href'] = 'www.google.com';

attrs['id'] = 'the_link'; ...

Is there a way to use the "repeat" to loop through my array and generate the attributes dynamically? (I know how to do it statically)

so I can have

<a href="www.google.com" id="the_link">abc</a>

Cheers

James

enter code here
A: 

Sorry, TAL doesn't have construct for this. You'll need fixed attributes:

tal:attributes="href attrs/href | nothing; id attrs/id | nothing"

or generate the tag yourself:

 ${structure php:generate_tag(attrs)}
porneL
${structure php:generate_tag(attrs)}where should I put this line into? I have tried this: <input type="text" ${structure php:render_input_attributes(field)}></input> and it failed
James Lin
Put it outside tag. It's supposed to output complete tag in an oldschool PHP way.
porneL