-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Inconsistent overriding of previously-defined helpers #1213
Comments
mwpastore
added a commit
to mwpastore/sinatra
that referenced
this issue
Dec 7, 2016
mwpastore
added a commit
to mwpastore/sinatra
that referenced
this issue
Dec 7, 2016
I'm not sure extent the affect of changing to |
Looks reasonable. |
jkowens
pushed a commit
to mwpastore/sinatra
that referenced
this issue
Mar 18, 2020
namusyaka
added a commit
that referenced
this issue
Nov 11, 2020
Revert "Use prepend instead of include for helpers. Fixes #1213"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a slight inconsistency with the order in which Sinatra applies helpers when those helpers may have been previously defined. This is probably best explained with an example:
One might reasonably expect one of two outcomes from the above:
/one
returns"1"
and/two
returns"2"
(i.e. the later-defined helpers override the previously-defined helpers)/one
returnsnil
and/two
returnsnil
(i.e. the previously-defined helpers are "sticky" and cannot be overridden)But what actually happens is:
/one
returnsnil
and/two
returns"2"
So previously-defined helpers can be overridden in the block, but not in an included helpers module. This is inconsistent and confusing. To fix it, let's
prepend
the module(s) instead ofinclude
-ing them.The text was updated successfully, but these errors were encountered: