Sha256: 9ff5f2adfe76f5f6ca49bfb2a3e4fc9554c563e921045cf4b7018b4e42481c8b

Contents?: true

Size: 794 Bytes

Versions: 3

Compression:

Stored size: 794 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 'ramaze/template/ezamar/engine'
require 'ramaze/helper/partial'

module Ezamar

  # A transformer for <render /> tags.

  class RenderPartial
    extend Ramaze::PartialHelper

    # 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

3 entries across 3 versions & 1 rubygems

Version Path
ramaze-0.1.4 lib/ramaze/template/ezamar/render_partial.rb
ramaze-0.2.1 lib/ramaze/template/ezamar/render_partial.rb
ramaze-0.2.0 lib/ramaze/template/ezamar/render_partial.rb