Sha256: d9335deb77d2b85d6cf9ea89cd76ed8ef037103e6e3c921fe864428895079677

Contents?: true

Size: 794 Bytes

Versions: 2

Compression:

Stored size: 794 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::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

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.3.5 lib/ramaze/template/ezamar/render_partial.rb
ramaze-0.3.0 lib/ramaze/template/ezamar/render_partial.rb