Class: Webgen::ContentProcessor::Haml

Inherits:
Object
  • Object
show all
Includes:
Deprecated
Defined in:
lib/webgen/contentprocessor/haml.rb

Overview

Processes content in Haml markup using the haml library.

Instance Method Summary collapse

Methods included from Deprecated

#deprecate

Instance Method Details

#call(context) ⇒ Object

Convert the content in haml markup to HTML.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/webgen/contentprocessor/haml.rb', line 11

def call(context)
  require 'haml'

  locals = {
    :context => context,
    :website => deprecate('website', 'context.website', context.website),
    :node => deprecate('node', 'context.node', context.content_node),
    :ref_node => deprecate('ref_node', 'context.ref_node', context.ref_node),
    :dest_node => deprecate('dest_node', 'context.dest_node', context.dest_node)
  }
  context.content = ::Haml::Engine.new(context.content, :filename => context.ref_node.alcn).
    render(Object.new, locals)
  context
rescue Exception => e
  raise RuntimeError, "Error converting Haml markup to HTML in <#{context.ref_node.alcn}>: #{e.message}", e.backtrace
end