Class: Tilt::AsciidoctorTemplate
- Inherits:
-
Template
- Object
- Template
- Tilt::AsciidoctorTemplate
- Defined in:
- lib/awestruct/handlers/template/asciidoc.rb
Class Method Summary collapse
Instance Method Summary collapse
- #allows_script? ⇒ Boolean
- #evaluate(scope, locals, &block) ⇒ Object
- #initialize_engine ⇒ Object
- #parse_headers(content, filter = /.*/) ⇒ Object
- #prepare ⇒ Object
Class Method Details
.engine_initialized? ⇒ Boolean
7 8 9 |
# File 'lib/awestruct/handlers/template/asciidoc.rb', line 7 def self.engine_initialized? defined? ::Asciidoctor::Document end |
Instance Method Details
#allows_script? ⇒ Boolean
23 24 25 |
# File 'lib/awestruct/handlers/template/asciidoc.rb', line 23 def allows_script? false end |
#evaluate(scope, locals, &block) ⇒ Object
19 20 21 |
# File 'lib/awestruct/handlers/template/asciidoc.rb', line 19 def evaluate(scope, locals, &block) @output ||= Asciidoctor.render(data, , &block) end |
#initialize_engine ⇒ Object
11 12 13 |
# File 'lib/awestruct/handlers/template/asciidoc.rb', line 11 def initialize_engine require_template_library 'asciidoctor' end |
#parse_headers(content, filter = /.*/) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/awestruct/handlers/template/asciidoc.rb', line 27 def parse_headers(content, filter = /.*/) doc = Asciidoctor.load(content, {:parse_header_only => true}) filtered = doc.attributes.select{|k,v| k =~ filter}.inject({}) do |hash, (k,v)| hash[k.gsub(filter, '')] = v hash end filtered['title'] = filtered['doctitle'] = doc.doctitle filtered['date'] ||= doc.attributes['revdate'] unless doc.attributes['revdate'].nil? filtered['author'] = doc.attributes['author'] unless doc.attributes['author'].nil? filtered end |
#prepare ⇒ Object
15 16 17 |
# File 'lib/awestruct/handlers/template/asciidoc.rb', line 15 def prepare [:header_footer] = false if [:header_footer].nil? end |