Sha256: fb38e718fc43377840f834b9983624720c63ec0c3691eac89f1f82faa5367c80

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

#
# File::       HAMLProcessor.rb
# Author::     wkm
# Copyright::  2009
# License::    GPL
#
# processes .haml source files to generate the associated HTML
#

module SiteFuel
  module Processor

    require 'sitefuel/extensions/Silently'

    # since the haml gem gives exec() warnings, we temporarily lower the verbosity
    # (last tested with 2.2.14, this might not be needed with a future version)
    silently { require 'haml' }

    require 'sitefuel/processors/AbstractStringBasedProcessor'
    require 'sitefuel/processors/HTMLProcessor'

    class HAMLProcessor < AbstractStringBasedProcessor

      def self.file_patterns
        ['.haml']
      end

      def self.default_filterset
        :generate
      end

      def self.filterset_generate
        [:generate, :minify]
      end

      # generate the raw .html file from a .haml file
      def filter_generate
        # to silence instance variable not initialized warnings from haml
        silently {
          engine = Haml::Engine.new(document)
          @document = engine.render
        }
      end

      # run the HTMLProcessor's whitespace filter
      def filter_minify
        @document = HTMLProcessor.filter_string(:whitespace, document)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitefuel-0.0.0b lib/sitefuel/processors/HAMLProcessor.rb
sitefuel-0.0.0a lib/sitefuel/processors/HAMLProcessor.rb