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
Post a Comment