h2o-php
h2o-php copied to clipboard
(Question) Method invoking on object variable?
I can't find any example but i think it must be possible somehow. Also, what about array literals?
What i am looking for is
{{ myClass.someMethod(['a' = 'b', 2, 3, 4]) }}
I assign my objects via render()
. I can {% debug %}
them, just not call any method.
I thought about making "MyClass" a filter collection, but then it is still not clear if i can set arrays inside the template to use them as option hashes. And it would be bad for a couple other inheritance related reasons.
Is this planned or already supported?
okay, found a generic solution to invoke methods with
$myClass->h2o_safe = get_class_methods($myClass);
$this->H2o->set($myClass->name, $myClass);
which allows me call methods without arguments
- How to pass arguments? I tried all markup i can think off but nothing gets through.
- How to create arguments? Is there a
{% set foo = bar %}
or maybe even something inline, like my example?
Well.. without 1 i don't need to know 2. Maybe i'll find it out but any hints are much appreciated.
I think the idea is for you to treat it all in php side, then "render" the HTML with the template with simple variables only.
A bit fancier stuff could be using the filters (build your own), which accepts arguments.