Refactor title and context into module #222

Merged
merged 2 commits into from Jan 5, 2017

Projects

None yet

3 participants

@fofr
Member
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 some commits Jan 4, 2017
@fofr fofr Move title and context logic into module
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.
6688b4d
@fofr fofr Protect `other` block in metadata
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.
4296ec2
@boffbowsh boffbowsh temporarily deployed to government-frontend-pr-222 Jan 4, 2017 Inactive
@gpeng
gpeng approved these changes Jan 5, 2017 View changes
@fofr fofr merged commit a6e6d36 into master Jan 5, 2017

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