-
-
Notifications
You must be signed in to change notification settings - Fork 394
[Twig] add computed properties system #266
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
Conversation
|
Should we make the public properties available via computed ( |
Ideally yes... just so that |
I believe so, yes. I only check get/no-get method prefix now (so |
8bfea5f to
040ad56
Compare
|
Ok, I think this is ready. I ensure |
weaverryan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! i just wanted to triple-check about reusing the Twig logic
| if (method_exists($this->component, $method = sprintf('%s%s', $prefix, ucfirst($name)))) { | ||
| return $method; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm guessing there wasn't a nice way to "steal" and re-use the Twig native functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was not...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at using twig_get_attribute but it requires injecting the twig environment and Source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, Source, that's a new class to me :)
040ad56 to
2c1bc0b
Compare
|
Rebased and conflicts resolved. |
|
Thank you Kevin! |
This adds a
computedcomponent template variable to make "computed methods" easier. In your component's template, to call a method on your component and cache the return (to use again later), instead of callingthis.methodName, callcomputed.methodName: