Class: Tilt::RDiscountTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/tilt/rdiscount.rb

Overview

Discount Markdown implementation. See: github.com/rtomayko/rdiscount

RDiscount is a simple text filter. It does not support scope or locals. The :smart and :filter_html options may be set true to enable those flags on the underlying RDiscount object.

Constant Summary collapse

ALIAS =
{
  :escape_html => :filter_html,
  :smartypants => :smart
}
FLAGS =
[:smart, :filter_html, :smartypants, :escape_html]

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

#allows_script?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/tilt/rdiscount.rb', line 34

def allows_script?
  false
end

#evaluate(scope, locals, &block) ⇒ Object



30
31
32
# File 'lib/tilt/rdiscount.rb', line 30

def evaluate(scope, locals, &block)
  @output ||= @engine.to_html
end

#flagsObject



21
22
23
# File 'lib/tilt/rdiscount.rb', line 21

def flags
  FLAGS.select { |flag| options[flag] }.map { |flag| ALIAS[flag] || flag }
end

#prepareObject



25
26
27
28
# File 'lib/tilt/rdiscount.rb', line 25

def prepare
  @engine = RDiscount.new(data, *flags)
  @output = nil
end