-
Notifications
You must be signed in to change notification settings - Fork 42
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
Replace control and action checks in page view code with page_is?() #1425
Comments
@prioux I can do it even though I find method name
If you like to introduce your own succinct combined helper I would rename |
It's just that the code gets really really long when we have something like <% if (controller_name == 'userfiles' && action_name == 'index') || (controller_name == 'tasks' && action_name == 'index') %
instead of (I believe) a much more readable <% if page_is?("userfiles#index", "tasks#index") %> If you don't like the names |
Ah, I also have errors in my examples here in the issue, the methods are |
I will correct the description. |
What about still several character longer, yet considering the average template width, I do not think it makes any difference. Well, by now I am getting used to |
While I do no see why why <% if page_is?("userfiles#index", "tasks#index") %> is more readable than <%
if ( controller_name == 'userfiles' && action_name == 'index' ) ||
( controller_name == 'tasks' && action_name == 'index' )
or <%
if current_page?( controller: 'userfiles', action: 'index' ) ||
current_page?( controller: 'tasks', action: 'index' )
it is certainly way shorter, and faster to type. A PR is submitted. Once approved I can submit a PR for cbrain-plugins-neuro |
In commit 6030bf1 I added two new
helper methods,
page_is?()
andpage_is_not?()
. See their description for more info.I have used these helpers in one layout page (see them in the same commit), but now we should go through the rest of the
interface code and search for code that say things like
and replace them by (respectively)
Since sometimes the pages are checking that a page is NOT a particular controller and action, there is also the method
page_is_not?()
, which is the equivalent of! page_is()
.The text was updated successfully, but these errors were encountered: