Sha256: c92f751a14bb5ac0cdffe0b52550c916476b23bb2424de5dfb16495d54a907d6

Contents?: true

Size: 808 Bytes

Versions: 3

Compression:

Stored size: 808 Bytes

Contents

require 'innate/helper/partial'

module Nagoro
  module Pipe
    # Pipe that transforms <render /> tags.
    #
    # the src parameter in the render tag will be used as first parameter to
    # render_partial, all other paramters are passed on as +options+.
    #
    # Example calling render_partial('/hello'):
    #   <render src="/hello" />
    #
    # Example calling render_partial('/hello', 'tail' => 'foo'):
    #   <render src="/hello" tail="foo" />
    #
    class RenderPartial < Base
      include Innate::Helper::Partial

      def tag_start(tag, attrs)
        if tag == 'render' and src = attrs.delete('src')
          append(render_partial(src, attrs))
        else
          super
        end
      end

      def tag_end(tag)
        super unless tag == 'render'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
Pistos-ramaze-2009.04.08 lib/ramaze/view/nagoro/render_partial.rb
manveru-ramaze-2009.04.01 lib/ramaze/view/nagoro/render_partial.rb
manveru-ramaze-2009.04.08 lib/ramaze/view/nagoro/render_partial.rb