Class: Awestruct::Handlers::InterpolationHandler

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

Instance Attribute Summary

Attributes inherited from BaseHandler

#delegate, #site

Instance Method Summary collapse

Methods inherited from BaseHandler

#content_line_offset, #content_syntax, #dependencies, #execute_shell, #front_matter, #inherit_front_matter, #input_mtime, #output_extension, #output_filename, #output_path, #path, #raw_content, #relative_source_path, #simple_name, #stale?, #to_chain

Constructor Details

#initialize(site, delegate) ⇒ InterpolationHandler

Returns a new instance of InterpolationHandler.



8
9
10
# File 'lib/awestruct/handlers/interpolation_handler.rb', line 8

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

Instance Method Details

#rendered_content(context, with_layouts = true) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/awestruct/handlers/interpolation_handler.rb', line 12

def rendered_content(context, with_layouts=true)
  content = delegate.raw_content

  return nil if content.nil?
  return content unless site.interpolate

  content = content.gsub( /\\/, '\\\\\\\\' )
  content = content.gsub( /\\\\#/, '\\#' )
  content = content.gsub( '@', '\@' )
  content = "%@#{content}@"
  c = context.instance_eval( content )
  c

end