Permalink
Browse files

Merge pull request #18 from crnixon/master

Add support for .org Tilt templates
  • Loading branch information...
2 parents 8653d43 + 2d479a3 commit 39b4155212cc64db9545e1f9c3b60fffe50a2bb0 @bdewey committed Dec 19, 2011
Showing with 31 additions and 1 deletion.
  1. +2 −1 README.rdoc
  2. +29 −0 lib/org-ruby/tilt.rb
View
@@ -16,6 +16,7 @@ extracting "content" from the orgfile as opposed to "metadata."
* Supports tables, block quotes, and block code
* Supports bold, italic, underline, strikethrough, and code inline formatting.
* Supports hyperlinks that are in double-brackets
+* Supports +.org+ views in Rails through Tilt.
* Upcoming: Handle export options specified in the org buffer.
== SYNOPSIS:
@@ -34,7 +35,7 @@ From Ruby code:
Orgmode::Parser.new(data)
-...will construct a new +Parser+ object.
+...will construct a new +Parser+ object.
== INSTALL:
View
@@ -0,0 +1,29 @@
+begin
+ require 'tilt'
+
+ module Tilt
+ class OrgTemplate < Template
+ def self.engine_initialized?
+ defined? ::Orgmode
+ end
+
+ def initialize_engine
+ require 'org-ruby'
+ end
+
+ def prepare
+ @engine = Orgmode::Parser.new(data)
+ @output = nil
+ end
+
+ def evaluate(scope, locals, &block)
+ @output ||= @engine.to_html
+ end
+ end
+ end
+
+ Tilt.register Tilt::OrgTemplate, 'org'
+
+rescue LoadError
+ # Tilt is not available.
+end

0 comments on commit 39b4155

Please sign in to comment.