lib/roda/plugins/render_each.rb
# For each value in enum, render the given template using the
# given opts.  The template and options hash are passed to +render+.
# Additional options supported:
# :local :: The local variable to use for the current enum value
#           inside the template.  An explicit +nil+ value does not
#           set a local variable.  If not set, uses the template name.
For each value in enum, render the given template using the
given opts.  The template and options hash are passed to +render+.
Additional options supported:
:local :: The local variable to use for the current enum value
inside the template.  An explicit +nil+ value does not
set a local variable.  If not set, uses the template name.
For each value in enum render the given template using the given opts . The template and options hash are passed to + render + . Additional options supported : : local :: The local variable to use for the current enum value inside the template . An explicit + nil + value does not set a local variable . If not set uses the template name .
def render_each(enum, template, opts=(no_opts = true; optimized_template = _cached_render_each_template_method(template); OPTS))
          if optimized_template
            return _optimized_render_each(enum, optimized_template, render_each_default_local(template), {})
          elsif opts.has_key?(:local)
            as = opts[:local]
          else
            as = render_each_default_local(template)
            if no_opts && optimized_template.nil? && (optimized_template = _optimized_render_method_for_locals(template, (locals = {as=>nil})))
              return _optimized_render_each(enum, optimized_template, as, locals)
            end
          end
          if as
            opts = opts.dup
            if locals = opts[:locals]
              locals = opts[:locals] = Hash[locals]
            else
              locals = opts[:locals] = {}
            end
            locals[as] = nil
            if (opts.keys - ALLOWED_KEYS).empty? && (optimized_template = _optimized_render_method_for_locals(template, locals))
              return _optimized_render_each(enum, optimized_template, as, locals)
            end
          end
          enum.map do |v|
            locals[as] = v if as
            render_template(template, opts)
          end.join
        end
def render_each ( enum , template , opts = ( no_opts = true ; optimized_template = _cached_render_each_template_method ( template ) ; OPTS ) ) if optimized_template return _optimized_render_each ( enum , optimized_template , render_each_default_local ( template ) , { } ) elsif opts . has_key? ( :local ) as = opts [ :local ] else as = render_each_default_local ( template ) if no_opts && optimized_template . nil? && ( optimized_template = _optimized_render_method_for_locals ( template , ( locals = { as => nil } ) ) ) return _optimized_render_each ( enum , optimized_template , as , locals ) end end if as opts = opts . dup if locals = opts [ :locals ] locals = opts [ :locals ] = Hash [ locals ] else locals = opts [ :locals ] = { } end locals [ as ] = nil if ( opts . keys - ALLOWED_KEYS ) . empty? && ( optimized_template = _optimized_render_method_for_locals ( template , locals ) ) return _optimized_render_each ( enum , optimized_template , as , locals ) end end enum . map do | v | locals [ as ] = v if as render_template ( template , opts ) end . join end
For each value in enum, render the given template using the
given opts.
For each value in enum render the given template using the given opts .
enum
template
opts
no_opts
optimized_template
_cached_render_each_template_method