Skip to content

Commit

Permalink
Update image card to include title
Browse files Browse the repository at this point in the history
  • Loading branch information
martikat committed Dec 2, 2024
1 parent 71bb2f9 commit f1daa90
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/views/markup/_image_card.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
7 changes: 4 additions & 3 deletions config/initializers/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def two_thirds

# @example
# {image_card}
# This is the title
#
# This is the body copy
#
# //path/to/image
Expand All @@ -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
Expand Down
19 changes: 19 additions & 0 deletions spec/helpers/content_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1daa90

Please sign in to comment.