Permalink
Browse files

added RedCloth

  • Loading branch information...
1 parent 23a141b commit 6518ccdf6509be1428862182e15332603db687d3 bry4n committed Dec 7, 2009
Showing with 39 additions and 0 deletions.
  1. +1 −0 README.md
  2. +18 −0 lib/tilt.rb
  3. +20 −0 test/spec_tilt_redclothtemplate.rb
View
@@ -30,6 +30,7 @@ Support for these template engines is included with the package:
Liquid .liquid liquid
Mustache .mustache mustache
RDiscount .markdown rdiscount
+ RedCloth .textile redcloth
Basic Usage
-----------
View
@@ -410,6 +410,24 @@ def evaluate(scope, locals, &block)
register 'md', RDiscountTemplate
+# RedCloth implementation. See:
+# http://redcloth.org/
+class RedClothTemplate < Template
+ def initialize_engine
+ require_template_library 'redcloth' unless defined? ::RedCloth
+ end
+
+ def compile!
+ @engine = RedCloth.new(data)
+ end
+
+ def evaluate(scope, locals, &block)
+ @engine.to_html
+ end
+end
+register 'textile', RedClothTemplate
+
+
# Mustache is written and maintained by Chris Wanstrath. See:
# http://github.com/defunkt/mustache
#
@@ -0,0 +1,20 @@
+require 'bacon'
+require 'tilt'
+
+begin
+ require 'redcloth'
+
+ describe Tilt::RedClothTemplate do
+ it "is registered for '.textile' files" do
+ Tilt['test.textile'].should.equal Tilt::RedClothTemplate
+ end
+
+ it "compiles and evaluates the template on #render" do
+ template = Tilt::RedClothTemplate.new { |t| "h1. Hello World!" }
+ template.render.should.equal "<h1>Hello World!</h1>"
+ end
+
+ end
+rescue LoadError => boom
+ warn "Tilt::RedClothTemplate (disabled)\n"
+end

0 comments on commit 6518ccd

Please sign in to comment.