Module: Roda::RodaPlugins::Render::InstanceMethods

Defined in:
lib/roda/plugins/render.rb

Instance Method Summary collapse

Instance Method Details

#render(template, opts = OPTS, &block) ⇒ Object Also known as: render_template

Render the given template. See Render for details.



249
250
251
252
253
# File 'lib/roda/plugins/render.rb', line 249

def render(template, opts = OPTS, &block)
  opts = parse_template_opts(template, opts)
  merge_render_locals(opts)
  retrieve_template(opts).render((opts[:scope]||self), (opts[:locals]||OPTS), &block)
end

#render_optsObject

Return the render options for the instance’s class. While this is not currently frozen, it may be frozen in a future version, so you should not attempt to modify it.



258
259
260
# File 'lib/roda/plugins/render.rb', line 258

def render_opts
  self.class.render_opts
end

#view(template, opts = OPTS) ⇒ Object

Render the given template. If there is a default layout for the class, take the result of the template rendering and render it inside the layout. See Render for details.



265
266
267
268
269
270
271
272
273
274
# File 'lib/roda/plugins/render.rb', line 265

def view(template, opts=OPTS)
  opts = parse_template_opts(template, opts)
  content = opts[:content] || render_template(opts)

  if layout_opts  = view_layout_opts(opts)
    content = render_template(layout_opts){content}
  end

  content
end