-
Notifications
You must be signed in to change notification settings - Fork 823
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
Include Template can't read parent's variables #9815
Comments
Just out of curiosity - does this behave differently if you use: return $this->customise([
'MyVar' => new MyClass()
])->renderWith('MyTemplate'); |
I believe this is by design |
related? to #8580 (comment) and also links to "by design". |
I'm not sure those two are related, but I even had this "problem" way back in ss3, I think. It's not necessarily intuitive (as in PHP an "include" will inherit the variables declared in scope), but the templates aren't PHP and I don't think there's any desire from maintainers to change this behaviour especially when a thought out and reasonable decision was made at the time to explicitly exclude the external scope. As such, I'm going to close this issue |
Thanks for the clarifications guys, it's ok that it's by design just something to keep in mind moving forward :) Thanks again. |
4.6.2
Description
I have to explicitly pass variables to Include templates when using
renderWith()
.Is this the correct behaviour?
Steps to Reproduce
This works
MyTemplate.ss
This doesn't work
This works
The text was updated successfully, but these errors were encountered: