Skip to content

Director

director.repeat(itr, fni)String

Directive that drives template loops in the for of or for in flavor

Parameters

NameTypeDescription
itr*The iterable array, array-like objects, etc. that will be repeated in the form of a for of loop
or an iterable non-symbol enumerable whose properties will be traversed in the form of a for in loop
fni*The function that will return a result for each iteration. for of will pass the item being iterated
and the index of the iteration. for in will pass the key, the value and the index.

Returns

  • String — The comulative fni result

Examples

js
${ repeat(it.metadata, (m, i) => `
 <meta name="${ m.name }" content="${ m.content }" />
`)}

director.comment()String

Tagged directive for consuming template comments

Returns

  • String — The comment replacement

Examples

js
${ comment` This is a comment that will get consumed` }

director.add(func)

Adds a directive function

Parameters

NameTypeDescription
funcfunctionThe named directive function to add

director.directivesArray.<Object>

Returns

  • Array.<Object> — An object array that contains { name:String, code: String } where name is the directive name and code is the code representation of the directive

director.toString()String

Returns

  • String — The named function directive code

Director.getDirectives(dirOrDirClass)Array.<Object>

Extracts class/sub-class Director.directives

Parameters

NameTypeDescription
dirOrDirClassDirector | Class.<Director>The Director instance or class to extract the
Director.directives from

Returns

  • Array.<Object> — An object array that contains { name:String, code: String } where name is the directive name and code is the code representation of the directive

Director.getString(dirOrDirClass)String

Extracts class/sub-class Director.toString()

Parameters

NameTypeDescription
dirOrDirClassClass.<Director>The Director instance or class to extract the Director.directives from

Returns

  • String — The named function directive code

Released under the MIT License.