Class: LiquidMarkdown::Render
- Inherits:
-
Object
- Object
- LiquidMarkdown::Render
- Defined in:
- lib/liquid_markdown/render.rb
Instance Attribute Summary collapse
-
#global_filter_proc ⇒ Object
readonly
setup your html layout layout to wrap around your LiquidMarkdown output layout = “<html><head></head><body>{yield}</body></html>”.
- #layout ⇒ Object
-
#liquid_hash ⇒ Object
readonly
setup your html layout layout to wrap around your LiquidMarkdown output layout = “<html><head></head><body>{yield}</body></html>”.
-
#liquid_settings ⇒ Object
Returns the value of attribute liquid_settings.
-
#markdown_settings ⇒ Object
Returns the value of attribute markdown_settings.
-
#template ⇒ Object
readonly
setup your html layout layout to wrap around your LiquidMarkdown output layout = “<html><head></head><body>{yield}</body></html>”.
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(template, liquid_hash = {}) ⇒ Render
constructor
A new instance of Render.
- #insert_into_template(rendered_content) ⇒ Object
- #liquidize ⇒ Object
- #markdown(template_value) ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(template, liquid_hash = {}) ⇒ Render
Returns a new instance of Render.
9 10 11 12 13 14 15 |
# 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. : output } end |
Instance Attribute Details
#global_filter_proc ⇒ Object (readonly)
setup your html layout layout to wrap around your LiquidMarkdown output layout = “<html><head></head><body>{yield}</body></html>”
5 6 7 |
# File 'lib/liquid_markdown/render.rb', line 5 def global_filter_proc @global_filter_proc end |
#layout ⇒ Object
41 42 43 |
# File 'lib/liquid_markdown/render.rb', line 41 def layout @layout ||= '' end |
#liquid_hash ⇒ Object (readonly)
setup your html layout layout to wrap around your LiquidMarkdown output layout = “<html><head></head><body>{yield}</body></html>”
5 6 7 |
# File 'lib/liquid_markdown/render.rb', line 5 def liquid_hash @liquid_hash end |
#liquid_settings ⇒ Object
Returns the value of attribute liquid_settings.
7 8 9 |
# File 'lib/liquid_markdown/render.rb', line 7 def liquid_settings @liquid_settings end |
#markdown_settings ⇒ Object
Returns the value of attribute markdown_settings.
7 8 9 |
# File 'lib/liquid_markdown/render.rb', line 7 def markdown_settings @markdown_settings end |
#template ⇒ Object (readonly)
setup your html layout layout to wrap around your LiquidMarkdown output layout = “<html><head></head><body>{yield}</body></html>”
5 6 7 |
# File 'lib/liquid_markdown/render.rb', line 5 def template @template end |
Instance Method Details
#html ⇒ Object
17 18 19 20 |
# 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) ⇒ Object
36 37 38 39 |
# 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 |
#liquidize ⇒ Object
31 32 33 34 |
# 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) ⇒ Object
27 28 29 |
# File 'lib/liquid_markdown/render.rb', line 27 def markdown(template_value) Kramdown::Document.new(template_value, @markdown_settings) end |
#text ⇒ Object
22 23 24 25 |
# File 'lib/liquid_markdown/render.rb', line 22 def text rendered_content = markdown(liquidize) rendered_content.to_plain_text end |