Class: Tilt::RDiscountTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/sinatra/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, #compile, #eval_file, #initialize, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

#compile!Object



408
409
410
# File 'lib/sinatra/tilt.rb', line 408

def compile!
  @engine = RDiscount.new(data, *flags)
end

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



412
413
414
# File 'lib/sinatra/tilt.rb', line 412

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

#flagsObject



400
401
402
# File 'lib/sinatra/tilt.rb', line 400

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

#initialize_engineObject



404
405
406
# File 'lib/sinatra/tilt.rb', line 404

def initialize_engine
  require_template_library 'rdiscount' unless defined? ::RDiscount
end