Method: YARD::Templates::Engine.render

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

+ (String) render(options = {})

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:

  • (Hash) options (defaults to: {}) — the options hash

Options Hash (options):

  • (Symbol) :format — default: :text — the default format
  • (Symbol) :type — default: nil — the :object’s type.
  • (Symbol) :template — default: :default — the default template

Returns:

  • (String) — the rendered template


71
72
73
74
75
76
77
78
79
80
# File 'lib/yard/templates/engine.rb', line 71

def render(options = {})
  set_default_options(options)
  mod = template(options[:template], options[:type], options[:format])
  
  if options[:serialize] != false
    with_serializer(options[:object], options[:serializer]) { mod.run(options) }
  else
    mod.run(options)
  end
end

Comments