This should already have worked, thanks to the method_missing-based #locals method that we expose in Hanami::View::Scope.
However, locals in in fact a local variable in the template rendering context, since that's the name of the one and only parameter for the method that Tilt compiles each template into. This means we can't access the #locals on our Scope instance without explicitly calling self.locals.
To fix this, we pass our scope._locals additionally into Tilt's render method, which will allow bare locals references to work inside templates.
Since this behavior evaded detection for so many years, we now have a dedicated test to make sure it remains working like we expect in the future.
This should already have worked, thanks to the
method_missing
-based#locals
method that we expose inHanami::View::Scope
.However,
locals
in in fact a local variable in the template rendering context, since that's the name of the one and only parameter for the method that Tilt compiles each template into. This means we can't access the#locals
on ourScope
instance without explicitly callingself.locals
.To fix this, we pass our
scope._locals
additionally into Tilt'srender
method, which will allow barelocals
references to work inside templates.Since this behavior evaded detection for so many years, we now have a dedicated test to make sure it remains working like we expect in the future.