Sha256: 3c86981556e008357b5f79379fc5845726ce3aa3ab541d4cc23243d51deb584d

Contents?: true

Size: 960 Bytes

Versions: 2

Compression:

Stored size: 960 Bytes

Contents

# -*- encoding: utf-8 -*-

module Webgen::ContentProcessor

  # Processes content in Haml markup using the +haml+ library.
  class Haml

    include Deprecated

    # Convert the content in +haml+ markup to HTML.
    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.absolute_lcn).
        render(Object.new, locals)
      context
    rescue Exception => e
      raise RuntimeError, "Error converting Haml markup to HTML in <#{context.ref_node.absolute_lcn}>: #{e.message}", e.backtrace
    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.8.20090507 lib/webgen/contentprocessor/haml.rb
webgen-0.5.8 lib/webgen/contentprocessor/haml.rb