Sha256: bfd585ab74357068ffa5737f77b0437024c6e3a7335509b63d09ce5c43976677

Contents?: true

Size: 971 Bytes

Versions: 1

Compression:

Stored size: 971 Bytes

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::Template
  class Haml < Template

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

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

    Ramaze::Controller.register_engine 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
        template = reaction_or_file(action)

        return '' unless template

        haml = ::Haml::Engine.new(template, ancestral_trait[:haml_options])
        haml.to_html(action.controller)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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