PDA

View Full Version : Simple Xtemplate question



FlaminPhoenix
13 Jun 2010, 10:13 PM
I have an xtemplate with:

'<tpl exec="another_class.another_function(values)"></tpl>',

as one of the lines in the tpl config option. Im returning a string value from the called function, but I cant get it to print the string out. Ive tried:

'<tpl exec="this.Return = another_class.another_function(values)">"this.Return"</tpl>',

and

'<tpl exec="parent.Return = another_class.another_function(values)">{Return}</tpl>',

both dont seem to work! Help!!

FlaminPhoenix
13 Jun 2010, 10:18 PM
Okay, the following seems to work:

'<tpl exec="Return = another_class.another_function(values)">{Return}</tpl>',

Can someone tell me if this is the best way to do it?

Condor
13 Jun 2010, 10:24 PM
I would have used:

'{[another_class.another_function(values)]}'

Ant1105
13 Jun 2010, 10:26 PM
Yes, I would do it the way Condor said too. Check out the XTemplate docs.


Anything between {[ ... ]} is considered code to be executed in the scope of the template.

FlaminPhoenix
13 Jun 2010, 10:36 PM
that does work! for everyone whose reading this: the earlier solution i posted seems to mess up the store somehow.. i wasnt able to read back the values from the store, as the variable that i was initializing it to and the field name in the object were the same :S