Skip to content
Snippets Groups Projects
Commit c6d25083 authored by Robert Speicher's avatar Robert Speicher
Browse files

Truncate page_description to 30 words

parent 5a3b9c97
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -30,9 +30,9 @@ module PageLayoutHelper
@page_description ||= page_description_default
 
if description.present?
@page_description = description
@page_description = description.squish
else
sanitize(@page_description.squish, tags: [])
sanitize(@page_description, tags: []).truncate_words(30)
end
end
 
Loading
Loading
Loading
Loading
@@ -22,6 +22,19 @@ describe PageLayoutHelper do
expect(helper.page_description).to eq 'Foo Bar Baz'
end
 
it 'truncates' do
helper.page_description <<-LOREM.strip_heredoc
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Donec quam felis,
ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa
quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,
arcu.
LOREM
expect(helper.page_description).to end_with 'quam felis,...'
end
it 'sanitizes all HTML' do
helper.page_description("<b>Bold</b> <h1>Header</h1>")
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment