From f1daa90df924e2ee4708bf9efed37e9769560531 Mon Sep 17 00:00:00 2001 From: martikat <78093815+martikat@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:29:30 +0000 Subject: [PATCH] Update image card to include title --- app/views/markup/_image_card.html.slim | 2 +- config/initializers/markdown.rb | 7 ++++--- spec/helpers/content_helper_spec.rb | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/views/markup/_image_card.html.slim b/app/views/markup/_image_card.html.slim index 76686145..a0f5fea5 100644 --- a/app/views/markup/_image_card.html.slim +++ b/app/views/markup/_image_card.html.slim @@ -2,4 +2,4 @@ .about-module-box-panel p.govuk-body-l = text - .about-module-box-panel style="min-height: 150px; background-image: url(#{image})" + .about-module-box-panel title=title style="min-height: 150px; background-image: url(#{image})" diff --git a/config/initializers/markdown.rb b/config/initializers/markdown.rb index f7c24ef6..05527704 100644 --- a/config/initializers/markdown.rb +++ b/config/initializers/markdown.rb @@ -52,6 +52,8 @@ def two_thirds # @example # {image_card} + # This is the title + # # This is the body copy # # //path/to/image @@ -61,9 +63,8 @@ def two_thirds def image_card pattern = build_regexp('image_card') @output = output.gsub(pattern) do - text, image = split_content Regexp.last_match(1) - - image_card_template.render(nil, text: text, image: image) + title, text, image = *Regexp.last_match(1).strip.split("\n") + image_card_template.render(nil, title: title, text: text, image: image) end self end diff --git a/spec/helpers/content_helper_spec.rb b/spec/helpers/content_helper_spec.rb index 4b9a8d88..0c1fd0ec 100644 --- a/spec/helpers/content_helper_spec.rb +++ b/spec/helpers/content_helper_spec.rb @@ -114,6 +114,25 @@ expect(html).to include '2 Pages' end end + + describe 'Image card' do + let(:input) do + <<~MARKUP + {image_card} + This is the image card title + + This is image text + + //This is the image + + {/image_card} + MARKUP + end + + it 'renders a title' do + expect(html).to include 'title="This is the image card title"' + end + end end describe 'Not found error' do