different templates depending on story text length

This commit is contained in:
2023-01-11 21:14:36 +02:00
parent 0055de6c83
commit efa95e82c7
7 changed files with 42 additions and 4 deletions

View File

@ -2,6 +2,16 @@ require "redcarpet"
module ApplicationHelper
# different template according to the amount of text
def render_story(story)
return "" unless story
text_length = story.text.length
template = "text"
template = "half" if text_length < 200
template = "pic" if text_length < 100
render partial: "stories/#{template}" , locals: {story: story}
end
def prose_classes
classes = "prose lg:prose-lg "
classes += "prose-headings:text-inherit "