Interface TemplateModule

Index

Methods

Methods

public addDelimiters(name: string, opener: string, closer: string)

Add a named set of Lo-Dash template delimiters.

You probably won't need to use this method, because the built-in delimiters should be sufficient, but you could always add {% %} or [% %] style delimiters.

Parameters

  • name: string
  • opener: string
  • closer: string

public date(date?: Date, format?: string): string

Format a date using the dateformat library. {@link http://github.com/felixge/node-dateformat}

note

if you don't include the mask argument, dateFormat.masks.default is used

Parameters

  • date?: Date optional
  • format?: string optional

Returns

string

public date(date?: number, format?: string): string

Parameters

  • date?: number optional
  • format?: string optional

Returns

string

public date(date?: string, format?: string): string

Parameters

  • date?: string optional
  • format?: string optional

Returns

string

public process(template: string): (options: any) => string

Process a Lo-Dash template string.

The template argument will be processed recursively until there are no more templates to process.

The default data object is the entire config object, but if options.data is set, that object will be used instead. The default template delimiters are <% %> but if options.delimiters is set to a custom delimiter name, those template delimiters will be used instead.

Inside templates, the grunt object is exposed so that you can do things like: <%= grunt.template.today('yyyy') %>

note

if the data object already has a grunt property, the grunt API will not be accessible in templates.

Parameters

  • template: string

Returns

(options: any) => string

public process(template: string, options: any): string

Parameters

  • template: string
  • options: any

Returns

string

public setDelimiters(name: string)

Set the Lo-Dash template delimiters to a predefined set in case you grunt.util._.template needs to be called manually.

The config delimiters <% %> are included by default.

Parameters

  • name: string

public today(format?: string): string

Format today's date using the dateformat library using the current date and time. {@link http://github.com/felixge/node-dateformat}

note

if you don't include the mask argument, dateFormat.masks.default is used

Parameters

  • format?: string optional

Returns

string