class Ezamar::RenderPartial

A transformer for <render /> tags.

Setup:

pipeline = Ramaze::Template::Ezamar::TRANSFORM_PIPELINE
pipeline.put_after(::Ezamar::Element, ::Ezamar::RenderPartial)
pipline.uniq!

See /examples/basic/partial.rb for usage.

Public Class Methods

transform(template) click to toggle source

Renders <render src=“/path” [optional=“option”, …]> in place.

Other options than `src` will be transformed to session parameters for the rendered action to use.

# File lib/ezamar/render_partial.rb, line 24
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