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

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

- (Boolean) allows_script?



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

def allows_script?
  false
end

- (Object) evaluate(scope, locals, &block)



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

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

- (Object) flags



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

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

- (Object) prepare



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

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