[DRE-commits] [ruby-org] 123/303: Add support for .org Tilt templates
Jérémy Bobbio
lunar at alioth.debian.org
Fri Aug 9 17:33:41 UTC 2013
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository ruby-org.
commit 2d479a33b693b48005d3271c807374324c9bfb77
Author: Clinton R. Nixon <crnixon at gmail.com>
Date: Fri Dec 16 10:20:37 2011 -0500
Add support for .org Tilt templates
---
README.rdoc | 3 ++-
lib/org-ruby/tilt.rb | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/README.rdoc b/README.rdoc
index 4445c12..628b4d9 100644
--- a/README.rdoc
+++ b/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:
diff --git a/lib/org-ruby/tilt.rb b/lib/org-ruby/tilt.rb
new file mode 100644
index 0000000..72e46d4
--- /dev/null
+++ b/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
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-org.git
More information about the Pkg-ruby-extras-commits
mailing list