Class: Awestruct::Handlers::ErbHandler

Inherits:
BaseHandler show all
Defined in:
lib/awestruct/handlers/erb_handler.rb

Constant Summary collapse

CHAIN =
Awestruct::HandlerChain.new( /\.erb$/,
  Awestruct::Handlers::FileHandler,
  Awestruct::Handlers::FrontMatterHandler,
  Awestruct::Handlers::ErbHandler,
  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) ⇒ ErbHandler

Returns a new instance of ErbHandler.



18
19
20
# File 'lib/awestruct/handlers/erb_handler.rb', line 18

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

Instance Method Details

#content_syntaxObject



34
35
36
# File 'lib/awestruct/handlers/erb_handler.rb', line 34

def content_syntax
  :erb
end

#output_extensionObject



30
31
32
# File 'lib/awestruct/handlers/erb_handler.rb', line 30

def output_extension
  File.extname( output_filename )
end

#output_filenameObject



26
27
28
# File 'lib/awestruct/handlers/erb_handler.rb', line 26

def output_filename
  File.basename( relative_source_path, '.erb' )
end

#rendered_content(context, with_layouts = true) ⇒ Object



38
39
40
41
# File 'lib/awestruct/handlers/erb_handler.rb', line 38

def rendered_content(context, with_layouts=true)
  erb = ERB.new( delegate.rendered_content( context, with_layouts) )
  erb.result( context.send( :binding ) )
end

#simple_nameObject



22
23
24
# File 'lib/awestruct/handlers/erb_handler.rb', line 22

def simple_name
  File.basename( File.basename( relative_source_path, '.erb' ), output_extension )
end