Paul Robert Lloyd
3 years ago
9 changed files with 58 additions and 0 deletions
@ -0,0 +1,11 @@
|
||||
class ContentController < ApplicationController |
||||
include ContentHelper |
||||
|
||||
def accessibility_statement |
||||
render_content_page :accessibility_statement |
||||
end |
||||
|
||||
def privacy_notice |
||||
render_content_page :privacy_notice, page_title: "Privacy notice for tenants and buyers of new social housing" |
||||
end |
||||
end |
@ -0,0 +1,14 @@
|
||||
module ContentHelper |
||||
def render_content_page(page_name, page_title: nil, locals: {}) |
||||
raw_content = File.read("app/views/content/#{page_name}.md") |
||||
content_with_erb_tags_replaced = ApplicationController.renderer.render( |
||||
inline: raw_content, |
||||
locals: locals |
||||
) |
||||
|
||||
@page_title = page_title || page_name.to_s.humanize |
||||
@page_content = GovukMarkdown.render(content_with_erb_tags_replaced).html_safe |
||||
|
||||
render "content/page" |
||||
end |
||||
end |
@ -0,0 +1,9 @@
|
||||
<%= content_for :title, @page_title %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds-from-desktop"> |
||||
<h1 class="govuk-heading-xl"><%= @page_title %></h1> |
||||
|
||||
<%= @page_content %> |
||||
</div> |
||||
</div> |
@ -0,0 +1,13 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe ContentHelper do |
||||
let(:page_name) { "privacy_notice" } |
||||
|
||||
describe "render content page" do |
||||
it "returns the page" do |
||||
expected_html = "Privacy notice" |
||||
expect(render_content_page(page_name)).to match(expected_html) |
||||
expect(page).to have_title("Privacy notice") |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue