Class: Awestruct::Handlers::TextileHandler

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

Constant Summary collapse

CHAIN =
Awestruct::HandlerChain.new( /\.textile$/,
  Awestruct::Handlers::FileHandler,
  Awestruct::Handlers::FrontMatterHandler,
  Awestruct::Handlers::InterpolationHandler,
  Awestruct::Handlers::TextileHandler,
  Awestruct::Handlers::LayoutHandler
)

Instance Attribute Summary

Attributes inherited from BaseHandler

#delegate, #site

Instance Method Summary collapse

Methods inherited from BaseHandler

#content_line_offset, #dependencies, #execute_shell, #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.



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

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

Instance Method Details

#content_syntaxObject



40
41
42
# File 'lib/awestruct/handlers/textile_handler.rb', line 40

def content_syntax
  :textile
end

#output_extensionObject



36
37
38
# File 'lib/awestruct/handlers/textile_handler.rb', line 36

def output_extension
  '.html'
end

#output_filenameObject



32
33
34
# File 'lib/awestruct/handlers/textile_handler.rb', line 32

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

#rendered_content(context, with_layouts = true) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/awestruct/handlers/textile_handler.rb', line 44

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



28
29
30
# File 'lib/awestruct/handlers/textile_handler.rb', line 28

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