Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Question) Method invoking on object variable? #50

Open
m3nt0r opened this issue Jun 10, 2012 · 2 comments
Open

(Question) Method invoking on object variable? #50

m3nt0r opened this issue Jun 10, 2012 · 2 comments

Comments

@m3nt0r
Copy link

m3nt0r commented Jun 10, 2012

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?

@m3nt0r
Copy link
Author

m3nt0r commented Jun 10, 2012

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

  1. How to pass arguments? I tried all markup i can think off but nothing gets through.
  2. 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.

@brunobraga
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants