Method: YARD::Templates::Engine.template!

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

.template!(path, full_paths = nil) ⇒ Template

Forces creation of a template at path within a full_path.

Parameters:

  • path (String)

    the path name of the template

  • full_paths (Array<String>) (defaults to: nil)

    the full path on disk of the template

Returns:

  • (Template)

    the template module representing the path



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/yard/templates/engine.rb', line 53

def template!(path, full_paths = nil)
  full_paths ||= [path]
  full_paths = [full_paths] unless full_paths.is_a?(Array)
  name = template_module_name(full_paths.first)
  begin; return const_get(name); rescue NameError; nil end

  mod = const_set(name, Module.new)
  mod.send(:include, Template)
  mod.send(:initialize, path, full_paths)
  mod
end