Class: Tilt::RDiscountTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/frank/tilt.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.

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, #eval_file, #initialize, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

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



640
641
642
# File 'lib/frank/tilt.rb', line 640

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

#flagsObject



626
627
628
# File 'lib/frank/tilt.rb', line 626

def flags
  [:smart, :filter_html].select { |flag| options[flag] }
end

#initialize_engineObject



630
631
632
633
# File 'lib/frank/tilt.rb', line 630

def initialize_engine
  return if defined? ::RDiscount
  require_template_library 'rdiscount'
end

#prepareObject



635
636
637
638
# File 'lib/frank/tilt.rb', line 635

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