|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
flowtron Smarty n00b
Joined: 24 May 2012 Posts: 1
|
Posted: Thu May 24, 2012 1:35 pm Post subject: find variables required to render a given template |
|
|
If you find the need to establish a list of variables used inside a template I found this way to get at one:
Code: |
$node = $smarty->createTemplate( "whatever.tpl" );
$code = $node->compiler->compileTemplate( $node );
echo sprintf( "<pre>%s</pre>",
print_r( $node->properties['variables'], true )
);
|
This will not list anything but the direct scope of the template; meaning nothing from any sub-templates! Use the getTags-function to establish included templates, then run the same on all of them.
Maybe the 3.2-development will provide us some nicer interface to the variables. On #smarty globe spoke of defaultVariableHandler - I'd say this should avoid the costly (extra) compilation |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|