Module | YARD::Templates::Template |
In: |
lib/yard/templates/template.rb
|
class | [RW] | |
extra_includes | [RW] |
Extra includes are mixins that are included after a template is created.
These mixins can be registered by plugins to operate on templates and
override behaviour.
Note that this array can be filled with modules or proc objects. If a proc object is given, the proc will be called with the {Template#options} hash containing relevant template information like the object, format, and more. The proc should return a module or nil if there is none. @example Adding in extra mixins to include on a template Template.extra_includes << MyHelper @example Conditionally including a mixin if the format is html Template.extra_includes << proc {|opts| MyHelper if opts.format == :html } @return [Array<Module, Proc>] a list of modules to be automatically included into any new template module |
options | [R] | |
section | [RW] |
Includes the {extra_includes} modules into the template object.
@param [Template] template the template object to mixin the extra includes. @param [SymbolHash] options the options hash containing all template information @return [void]
Returns the contents of a file. If allow_inherited is set to true, use +{{{super}}}+ inside the file contents to insert the contents of the file from an inherited template. For instance, if +templates/b+ inherits from +templates/a+ and file "test.css" exists in both directories, both file contents can be retrieved by having +templates/b/test.css+ look like:
{{{__super__}}} ... body { css styles here } p.class { other styles }
@param [String] basename the name of the file @param [Boolean] allow_inherited whether inherited templates can
be inserted with +{{{__super__}}}+
@return [String] the contents of a file identified by basename. All
template paths (including any mixed in templates) are searched for the file
Runs a template on sects using extra options. This method should not be called directly. Instead, call the class method {ClassMethods#run}
@param [Hash, nil] opts any extra options to apply to sections @param [Section, Array] sects a section list of sections to render @param [Fixnum] start_at the index in the section list to start from @param [Boolean] break_first if true, renders only the first section @yield [opts] calls for the subsections to be rendered @yieldparam [Hash] opts any extra options to yield @return [String] the rendered sections joined together
Sets the sections (and subsections) to be rendered for the template
@example Sets a set of erb sections
sections :a, :b, :c # searches for a.erb, b.erb, c.erb
@example Sets a set of method and erb sections
sections :a, :b, :c # a is a method, the rest are erb files
@example Sections with subsections
sections :header, [:name, :children] # the above will call header.erb and only renders the subsections # if they are yielded by the template (see #yieldall)
@param [Array<Symbol, String, Template, Array>] args the sections
to use to render the template. For symbols and strings, the section will be executed as a method (if one exists), or rendered from the file "name.erb" where name is the section name. For templates, they will have {Template::ClassMethods#run} called on them. Any subsections can be yielded to using yield or {#yieldall}
Yields all subsections with any extra options
@param [Hash] opts extra options to be applied to subsections