Class: Awestruct::Handlers::TextileHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/awestruct/handlers/textile_handler.rb

Instance Attribute Summary

Attributes inherited from BaseHandler

#delegate, #site

Instance Method Summary collapse

Methods inherited from BaseHandler

#content_line_offset, #front_matter, #inherit_front_matter, #input_mtime, #output_path, #path, #raw_content, #relative_source_path, #stale?, #to_chain

Constructor Details

#initialize(site, delegate) ⇒ TextileHandler

Returns a new instance of TextileHandler.



9
10
11
# File 'lib/awestruct/handlers/textile_handler.rb', line 9

def initialize(site, delegate)
  super( site, delegate )
end

Instance Method Details

#content_syntaxObject



25
26
27
# File 'lib/awestruct/handlers/textile_handler.rb', line 25

def content_syntax
  :textile
end

#output_extensionObject



21
22
23
# File 'lib/awestruct/handlers/textile_handler.rb', line 21

def output_extension
  '.html'
end

#output_filenameObject



17
18
19
# File 'lib/awestruct/handlers/textile_handler.rb', line 17

def output_filename
  File.basename( relative_source_path, '.textile' ) + '.html'
end

#rendered_content(context, with_layouts = true) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/awestruct/handlers/textile_handler.rb', line 29

def rendered_content(context, with_layouts=true)
  rendered = ''
  # security and rendering restrictions
  # ex. site.textile = ['no_span_caps']
  restrictions = (site.textile || []).map { |r| r.to_sym }
  # a module of rule functions is included in RedCloth using RedCloth.send(:include, MyRules)
  # rule functions on that module are activated by setting the property site.textile_rules
  # ex. site.textile_rules = ['emoticons']
  rules = context.site.textile_rules ? context.site.textile_rules.map { |r| r.to_sym } : []
  RedCloth.new( delegate.rendered_content( context, with_layouts ), restrictions ).to_html(*rules)
end

#simple_nameObject



13
14
15
# File 'lib/awestruct/handlers/textile_handler.rb', line 13

def simple_name
  File.basename( relative_source_path, '.textile' ) 
end