Method: YARD::Templates::Engine.render

Defined in:
lib/yard/templates/engine.rb

.render(options = {}) ⇒ String

Renders a template on a code object using a set of default (overridable) options. Either the :object or :type keys must be provided.

If a :serializer key is provided and :serialize is not set to false, the rendered contents will be serialized through the Serializers::Base object. See with_serializer.

Examples:

Renders an object with html formatting

Engine.render(:format => :html, :object => obj)

Renders without an object

Engine.render(:type => :fulldoc, :otheropts => somevalue)

Parameters:

  • options (Hash) (defaults to: {})

    the options hash

Options Hash (options):

  • :format (Symbol) — default: :text

    the default format

  • :type (Symbol) — default: nil

    the :object’s type.

  • :template (Symbol) — default: :default

    the default template

Returns:

  • (String)

    the rendered template



82
83
84
85
86
87
88
89
90
91
# File 'lib/yard/templates/engine.rb', line 82

def render(options = {})
  options = set_default_options(options)
  mod = template(options.template, options.type, options.format)

  if options.serializer && options.serialize != false
    with_serializer(options.object, options.serializer) { mod.run(options) }
  else
    mod.run(options)
  end
end