File: tilt.rb

package info (click to toggle)
ruby-org 0.9.12-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,852 kB
  • sloc: ruby: 3,044; lisp: 50; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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