make test sectio multi column

This commit is contained in:
2022-12-29 13:47:42 +02:00
parent 547d750034
commit 137a768a6d
7 changed files with 36 additions and 15 deletions

View File

@ -18,6 +18,14 @@ module Merged
self.renderer.render(text).html_safe
end
def split_section(section)
return [""] if section.text.blank?
words = self.renderer.render(section.text).split
bins = (words.length + 3) / section.option("columns").to_i
parts = words.each_slice(bins).to_a
parts.collect{|part| part.join(" ").html_safe}
end
def aspect_ratio image
x , y = image.aspect_ratio
"#{x} / #{y}"

View File

@ -2,6 +2,14 @@ module Merged
module ViewHelper
include MergedHelper
def rows( text )
return 5 if text.blank?
text = text.text unless text.is_a?(String)
rows = (text.length / 60).to_i
return 5 if rows < 5
rows
end
# background image as inline style
def bg(section , clazz = "")
attributes = {class: clazz}