Sha256: b59ff7eecd5661c569127263e13ea839f22d775324cb01b501f5f8c8acd06ed3

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 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 'sass/engine'

module Ramaze
  module Template

    # Is responsible for compiling a template using the Sass CSS templating engine.
    # Can be found at: http://haml.hamptoncatlin.com/

    class Sass < Template

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

      trait :sass_options => {
        :locals => {}
      }

      ENGINES[self] = %w[ sass ]

      class << self

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

        def transform action
          Response.current['Content-Type'] = "text/css"
          sass = wrap_compile(action)
          sass.to_css()
        end

        # Instantiates Sass::Engine with the template and sass_options from
        # the trait.

        def compile(action, template)
          ::Sass::Engine.new(template, ancestral_trait[:sass_options])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.1.4 lib/ramaze/template/sass.rb
ramaze-0.2.0 lib/ramaze/template/sass.rb