Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make 'context' public in lambda helper #137
There have been a few cases that I found myself wishing I could touch the context but I was able to work around them in ok ways. This one is the one that has me resorting to ReflectionClass etc. but I think I have a way around this by just writing a little more in the lambda fcn.
You've prolly heard it before, but "prepare your view" might apply here too. I typically use one ViewModel (or Presenter) per template file, and use that to handle the logic needed to bridge the data to the template. I don't know what your ViewModel would look like, but it's usually pretty easy to handle cases like this at that level rather than in lambdas or in the template itself. Then you'd have clean testable code bundled up in the ViewModels, and your invocation wouldn't be much different than it currently is:
$m->render('sometemplate', new SomeTemplateViewModel($data));