class LiquidMarkdown::Render
Attributes
global_filter_proc[R]
setup your html layout layout to wrap around your LiquidMarkdown output
layout = “<html><head></head><body>{{yield}}</body></html>”
layout[W]
liquid_hash[R]
setup your html layout layout to wrap around your LiquidMarkdown output
layout = “<html><head></head><body>{{yield}}</body></html>”
liquid_settings[RW]
markdown_settings[RW]
template[R]
setup your html layout layout to wrap around your LiquidMarkdown output
layout = “<html><head></head><body>{{yield}}</body></html>”
Public Class Methods
new(template, liquid_hash={})
click to toggle source
# File lib/liquid_markdown/render.rb, line 9 def initialize(template, liquid_hash={}) @template = template @liquid_hash = liquid_hash @markdown_settings = {auto_ids: false, parse_block_html: true} @liquid_settings = {strict_filters: true, strict_variables: true} @global_filter_proc = ->(output) { output.is_a?(String) ? output.strip_html_tags : output } end
Public Instance Methods
html()
click to toggle source
# File lib/liquid_markdown/render.rb, line 17 def html rendered_content = markdown(liquidize) insert_into_template(rendered_content.to_html) end
insert_into_template(rendered_content)
click to toggle source
# File lib/liquid_markdown/render.rb, line 36 def insert_into_template(rendered_content) return rendered_content if layout == '' layout.sub('{{yield}}', rendered_content) end
layout()
click to toggle source
# File lib/liquid_markdown/render.rb, line 41 def layout @layout ||= '' end
liquidize()
click to toggle source
# File lib/liquid_markdown/render.rb, line 31 def liquidize Liquid::Template.parse(@template) .render(@liquid_hash, @liquid_settings, global_filter: @global_filter_proc) end
markdown(template_value)
click to toggle source
# File lib/liquid_markdown/render.rb, line 27 def markdown(template_value) Kramdown::Document.new(template_value, @markdown_settings) end
text()
click to toggle source
# File lib/liquid_markdown/render.rb, line 22 def text rendered_content = markdown(liquidize) rendered_content.to_plain_text end