How get object's method by string in twig -


in php can object method as:

$methodname="getid"; $obj->{$methodname}(); 

is there such features in twig?

upd: :

{% set method='getid' %} {{ obj[method]() }} 

now use extention:

{{ getter(obj, method) }} 

but maybe there standard solution?

a standard solution exist, similar extension:

{{ attribute(obj, method) }} 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -