Sha256: 68c8c6268e43c313651564033ebc00ce398fe443efc3ec287139041a2938ed8a

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

#          Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require 'haml/engine'

module Ramaze
  module Template
    class Haml < Template

      # Custom HAML-options for your controller to be merged.

      trait :haml_options => {
        :locals => {}
      }

      ENGINES[self] = %w[ haml ]

      class << self

        # Transform any String via Haml, takes optionally an hash with the
        # haml_options that you can set also by
        #   trait :haml_options => {}
        # if you pass the options it will merge the trait with them. (your
        # options override the defaults from trait[:haml_options]

        def transform action
          haml = wrap_compile(action)
          haml.to_html(action.instance)
        end

        # Instantiates Haml::Engine with the template and haml_options from
        # the trait.

        def compile(action, template)
          ::Haml::Engine.new(template, ancestral_trait[:haml_options])
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ramaze-0.1.2 lib/ramaze/template/haml.rb