File: asciidoc.rb

package info (click to toggle)
ruby-tilt 2.0.0%2Breally1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 476 kB
  • ctags: 411
  • sloc: ruby: 3,546; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
require 'tilt/template'

# AsciiDoc see: http://asciidoc.org/
module Tilt
  # Asciidoctor implementation for AsciiDoc see:
  # http://asciidoctor.github.com/
  #
  # Asciidoctor is an open source, pure-Ruby processor for
  # converting AsciiDoc documents or strings into HTML 5,
  # DocBook 4.5 and other formats.
  class AsciidoctorTemplate < Template
    self.default_mime_type = 'text/html'

    def self.engine_initialized?
      defined? ::Asciidoctor::Document
    end

    def initialize_engine
      require_template_library 'asciidoctor'
    end

    def prepare
      options[:header_footer] = false if options[:header_footer].nil?
    end

    def evaluate(scope, locals, &block)
      @output ||= Asciidoctor.render(data, options, &block)
    end

    def allows_script?
      false
    end
  end
end