Skip to content
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

Make use content_for method #33

Merged
merged 1 commit into from
Jan 11, 2017
Merged

Make use content_for method #33

merged 1 commit into from
Jan 11, 2017

Conversation

iguchi1124
Copy link
Contributor

@iguchi1124 iguchi1124 commented Dec 30, 2016

I'd prefer to use content_for tag when I want to set title tag from view partials.

This pull-request fixes to set title by using content_for and yield clause which are view helper methods.

20161230172101_img20161230-9-14xxy7t

@iguchi1124 iguchi1124 changed the title Make use content_for clause [WIP] Make use content_for clause Dec 30, 2016
@iguchi1124 iguchi1124 changed the title [WIP] Make use content_for clause Make use content_for clause Dec 30, 2016
@eagletmt
Copy link
Member

eagletmt commented Jan 1, 2017

Could you explain why you think content_for is preferable?

@iguchi1124 iguchi1124 changed the title Make use content_for clause Make use content_for method Jan 1, 2017
@iguchi1124
Copy link
Contributor Author

iguchi1124 commented Jan 1, 2017

Simple instance variable doesn't have informations enough, it is hard to know that where / how used to. that would be complicated.

The content_for method provides us explicitly way to yields shared html from each views.

@@ -59,7 +59,7 @@ html

aside.right-side
section.content-header
h1= raw(@content_title || @title)
h1= raw yield(:content_title) || yield(:title)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yield(:undefined_symbol) returns "" (empty string).

So yield(:content_title) || yield(:title) returns always yield(:content_title) value.
Do you want yield(:content_title).presence || yield(:title) here?

Copy link
Contributor Author

@iguchi1124 iguchi1124 Jan 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
fixed

@@ -20,6 +20,9 @@
expect(page).to have_selector('#definitions_list table tbody tr', count: 1)

expect(page).to have_content('There are no working jobs.')
expect(page).to have_title('Dashboard « Kuroko 2')
expect(page).to have_selector('i.fa.fa-dashboard', text: '')
expect(page).to have_content(' Dashboard')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dashboard may be displayed in other places.
How about using have_selector('h1', text: /Dashboard/) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! thanks!
fixed

Copy link
Member

@eisuke eisuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eisuke eisuke merged commit 6a43989 into cookpad:master Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants