Module: Breeze::SharedHelper
- Included in:
- BreezeHelper
- Defined in:
- lib/breeze/shared_helper.rb
Instance Method Summary collapse
- #markdown(text, lang = "") ⇒ Object
- #markdown_image(section, lang = "") ⇒ Object
- #prose_classes ⇒ Object
- #renderer ⇒ Object
- #rows(text) ⇒ Object
Instance Method Details
#markdown(text, lang = "") ⇒ Object
27 28 29 30 31 |
# File 'lib/breeze/shared_helper.rb', line 27 def markdown(text , lang = "") text = text.text_text(lang) unless text.is_a?(String) return "" if text.blank? self.renderer.render(text).html_safe end |
#markdown_image(section, lang = "") ⇒ Object
20 21 22 23 24 25 |
# File 'lib/breeze/shared_helper.rb', line 20 def markdown_image(section, lang = "") return "" unless section.text down = self.renderer.render(section.text_text(lang)) image = image_for(section) down.gsub("IMAGE" , image).html_safe end |
#prose_classes ⇒ Object
14 15 16 17 18 |
# File 'lib/breeze/shared_helper.rb', line 14 def prose_classes classes = "prose md:prose-lg lg:prose-xl max-w-none " classes += "prose-headings:text-inherit " { class: classes } end |
#renderer ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/breeze/shared_helper.rb', line 6 def renderer = {hard_wrap: true , autolink: true, no_intra_emphasis: true , safe_links_only: true, no_styles: true , fenced_code_blocks: true, link_attributes: { target: '_blank' }} html = Redcarpet::Render::HTML.new() Redcarpet::Markdown.new(html, ) end |
#rows(text) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/breeze/shared_helper.rb', line 33 def rows( text ) return 5 if text.blank? text = text.text unless text.is_a?(String) return 5 if text.blank? rows = (text.length / 50).to_i rows += text.count("\n") return 5 if rows < 5 rows end |