Sha256: 994bb7a13612ea1347751c5c59ba3ee50027ec9f0e3c70adf6eb2db9d7911356

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'awestruct/handlers/base_handler'

require 'haml'

module Awestruct
  module Handlers
    class HamlHandler < BaseHandler

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

      def simple_name
        File.basename( self.path, "#{output_extension}.haml" )
      end

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

      def output_extension
        File.extname( File.basename( path, '.haml' ) )
      end

      def rendered_content(context, with_layouts=true)
        options = context.site.haml? ? context.site.haml : {}
        options = options.inject({}){ |hash,(key,value)| 
          hash[key.to_sym] = value
          hash
        }
        options[:relative_source_path] = context.page.relative_source_path
        options[:filename] = delegate.path
        options[:line]     = delegate.content_line_offset + 1
        options[:site] = context.site
        haml_engine = Haml::Engine.new( delegate.raw_content, options )
        haml_engine.render( context )
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awestructx-0.4.0 lib/awestruct/handlers/haml_handler.rb