Sha256: 93e425daebdc7d2e7539be7ee6a96c182f03a68b787cf87a8363bf469ed55a05

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

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

require 'ramaze/template/ezamar/engine'
require 'ramaze/helper/partial'

module Ezamar

  # A transformer for <render /> tags.

  class RenderPartial
    extend Ramaze::Helper::Partial

    # Renders <render src="/path" [optional="option", ...]> in place.
    #
    # Other options than `src` will be transformed to session parameters for the
    # rendered action to use.

    def self.transform(template)
      template.gsub!(/<render (.*?) \/>/) do |m|
        args = Hash[*$1.scan(/(\S+)=["'](.*?)["']/).flatten]
        if src = args.delete('src')
          render_partial(src, args)
        end
      end

      template
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.3.9.1 lib/ramaze/template/ezamar/render_partial.rb
ramaze-0.3.9 lib/ramaze/template/ezamar/render_partial.rb