improving the text section, now with one image
This commit is contained in:
@ -12,20 +12,18 @@ module Merged
|
||||
Redcarpet::Markdown.new(html, options)
|
||||
end
|
||||
|
||||
def markdown_image(section)
|
||||
down = self.renderer.render(section.text)
|
||||
image = image_for(section)
|
||||
down.gsub("IMAGE" , image).html_safe
|
||||
end
|
||||
|
||||
def markdown(text)
|
||||
text = text.text unless text.is_a?(String)
|
||||
return "" if text.blank?
|
||||
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}"
|
||||
|
@ -87,6 +87,20 @@ module Merged
|
||||
{class: clazz }
|
||||
end
|
||||
|
||||
def text_column_option( section)
|
||||
option = section.option('columns')
|
||||
option = 2 if option.blank?
|
||||
case option
|
||||
when "3"
|
||||
columns = "columns-1 md:columns-2 lg:columns-3"
|
||||
when "4"
|
||||
columns = "columns-1 md:columns-2 lg:columns-3 xl:columns-4"
|
||||
else # two
|
||||
columns = "columns-1 md:columns-2"
|
||||
end
|
||||
{class: columns }
|
||||
end
|
||||
|
||||
def column_option(section)
|
||||
option = section.option('columns')
|
||||
option = 2 if option.blank?
|
||||
|
Reference in New Issue
Block a user