make test sectio multi column
This commit is contained in:
@ -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}"
|
||||
|
@ -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}
|
||||
|
Reference in New Issue
Block a user