Class: Tilt::RDiscountTemplate
- Inherits:
-
Template
show all
- Defined in:
- lib/tilt/markdown.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
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Methods inherited from Template
#basename, cached_evaluate, #compile_template_method, #eval_file, #evaluate_source, #initialize, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Class Method Details
+ (Boolean) engine_initialized?
24
25
26
|
# File 'lib/tilt/markdown.rb', line 24
def self.engine_initialized?
defined? ::RDiscount
end
|
Instance Method Details
- (Object) evaluate(scope, locals, &block)
37
38
39
|
# File 'lib/tilt/markdown.rb', line 37
def evaluate(scope, locals, &block)
@output ||= @engine.to_html
end
|
- (Object) flags
20
21
22
|
# File 'lib/tilt/markdown.rb', line 20
def flags
FLAGS.select { |flag| options[flag] }.map { |flag| ALIAS[flag] || flag }
end
|
- (Object) initialize_engine
28
29
30
|
# File 'lib/tilt/markdown.rb', line 28
def initialize_engine
require_template_library 'rdiscount'
end
|
- (Object) prepare
32
33
34
35
|
# File 'lib/tilt/markdown.rb', line 32
def prepare
@engine = RDiscount.new(data, *flags)
@output = nil
end
|