Class: Middleman::Renderers::RedcarpetTemplate
- Inherits:
-
Tilt::RedcarpetTemplate
- Object
- Tilt::RedcarpetTemplate
- Middleman::Renderers::RedcarpetTemplate
- Defined in:
- lib/middleman-core/renderers/redcarpet.rb
Constant Summary collapse
- ALIASES =
because tilt has decided to convert these in the wrong direction
{ escape_html: :filter_html }.freeze
Instance Method Summary collapse
- #evaluate(scope, _) ⇒ Object
-
#generate_renderer ⇒ Object
Overwrite built-in Tilt version.
-
#initialize(*args, &block) ⇒ RedcarpetTemplate
constructor
A new instance of RedcarpetTemplate.
Constructor Details
#initialize(*args, &block) ⇒ RedcarpetTemplate
Returns a new instance of RedcarpetTemplate.
13 14 15 16 17 |
# File 'lib/middleman-core/renderers/redcarpet.rb', line 13 def initialize(*args, &block) super @context = @options[:context] if @options.key?(:context) end |
Instance Method Details
#evaluate(scope, _) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/middleman-core/renderers/redcarpet.rb', line 47 def evaluate(scope, _) @output ||= begin MiddlemanRedcarpetHTML.scope = @context || scope @engine.render(data) end end |
#generate_renderer ⇒ Object
Overwrite built-in Tilt version. Don't overload :renderer option with smartypants Support renderer-level options
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/middleman-core/renderers/redcarpet.rb', line 22 def generate_renderer return .delete(:renderer) if .key?(:renderer) # Pick a renderer renderer = MiddlemanRedcarpetHTML if .delete(:smartypants) # Support SmartyPants renderer = Class.new(renderer) do include ::Redcarpet::Render::SmartyPants end end # Renderer Options possible_render_opts = [:filter_html, :no_images, :no_links, :no_styles, :safe_links_only, :with_toc_data, :hard_wrap, :xhtml, :prettify, :link_attributes] = possible_render_opts.each_with_object({}) do |opt, sum| sum[opt] = .delete(opt) if .key?(opt) end renderer.new() end |