Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #18 from crnixon/master

Add support for .org Tilt templates
  • Loading branch information...
commit 39b4155212cc64db9545e1f9c3b60fffe50a2bb0 2 parents 8653d43 + 2d479a3
@bdewey authored
Showing with 31 additions and 1 deletion.
  1. +2 −1  README.rdoc
  2. +29 −0 lib/org-ruby/tilt.rb
View
3  README.rdoc
@@ -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
29 lib/org-ruby/tilt.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.