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

Refactor title and context into module #222

Merged
merged 2 commits into from Jan 5, 2017
Merged

Refactor title and context into module #222

merged 2 commits into from Jan 5, 2017

Conversation

@fofr
Copy link
Contributor

@fofr fofr commented Jan 4, 2017

Clean up each format’s template by moving format specific logic into module, with overrides in format presenters.

Default:

  • Content item title
  • Context based on document type
  • Long title length

This makes it difficult to include titles with the wrong attributes.
It also makes it easy to link to translations to any format – if a format has translations, then the links will display – protecting against accidental omission as with the speeches format.

One further commit:

  • Protect against overwriting properties on the other hash provided to metadata and document footer components

A template for a standard format is now as simple as:

<%= content_for :page_class, @content_item.format.dasherize %>
<%= content_for :title, "#{@content_item.page_title} - #{t("content_item.format.#{@content_item.document_type}", count: 1)}" %>
<%= content_for :meta_description, @content_item.description %>

<%= render 'shared/title_and_translations', content_item: @content_item %>
<%= render 'shared/withdrawal_notice', content_item: @content_item %>
<%= render 'shared/metadata', content_item: @content_item %>
<%= render 'shared/description', description: @content_item.description %>
<%= render 'shared/sidebar_with_body', content_item: @content_item %>
<%= render 'govuk_component/document_footer', @content_item.document_footer %>
fofr added 2 commits Jan 4, 2017
Clean up each format’s template by moving format specific logic into
module, with overrides in format presenters.

Default:
* Content item title
* Context based on document type
* Long title length

This makes it difficult to include titles with the wrong attributes, eg
missing long title length. It also highlights which formats are
different.
Previously, by setting `m[:other]`, custom values already set could be
accidentally wiped.

Instead start with an empty [:other] hash which the component handles
correctly, then append to it as required.
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-222 Jan 4, 2017 Inactive
@gpeng
gpeng approved these changes Jan 5, 2017
@fofr fofr merged commit a6e6d36 into master Jan 5, 2017
1 check passed
1 check passed
continuous-integration/jenkins/branch This commit looks good
Details
@fofr fofr deleted the refactor-titles branch Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.