Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mustr

Hierarchy

  • EventEmitter
    • Mustr

Implements

Index

Constructors

constructor

Properties

cwd

cwd: string = process.cwd()

loaded

loaded: boolean

log

log: ILogger

options

options: IMustrOptions

outputPath

outputPath: string

pargv

pargv: IPargv

registerPath

registerPath: string

templates

templates: ITemplates

templatesGlob

templatesGlob: string[]

templatesPath

templatesPath: string

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

  • addListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Returns ( string | symbol ) []

generate

  • Generate Generates and renders a template.

    Parameters

    • Optional name: string

      the name of the template to generate.

    • Optional output: string | IMetadata

      the output name/path to use when rendering.

    • Optional options: IMetadata

      any metadata to merge for rendering.

    Returns ITemplate

getMaxListeners

  • getMaxListeners(): number
  • Returns number

Private hasMatter

  • hasMatter(str: any): boolean
  • Has Matter Tests if string contains front matter.

    Parameters

    • str: any

      the string to inspect.

    Returns boolean

Private hasTemplate

  • hasTemplate(str: any): boolean
  • Has Template Loosly check if string contains template chars.

    Parameters

    • str: any

      the string to inspect.

    Returns boolean

help

  • help(): void
  • Help Displays help and usage information.

    Returns void

init

  • init(force?: boolean): void
  • Init Initializes Mustr for current project

    Parameters

    • Optional force: boolean

      when true forces init.

    Returns void

inject

  • Inject Creates a file stream reading chunks until match. Upon match the provided value is injected. NOTE: lines are auto updated with the correct line ending for returns.

    Parameters

    • filename: string

      the file name to inject into.

    • search: string | RegExp

      the string or expression to match.

    • value: string | string[] | InjectCallback

      the value or callback for injecting upon match.

    • replace: boolean | NodeCallback

      when true the matched value is replaced.

    • Optional done: NodeCallback

      the callback on file written.

    Returns void

isValid

  • isValid(): void

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

load

normalize

  • Normalize Parses/normalizes a template name, path or static template string. When passing a name it searches loaded template paths and matches the filename to the template name passed.

    Parameters

    • template: string

      the template name, path or static template string.

    Returns ITemplate

Private normalizedExt

  • normalizedExt(ext: any): string
  • Normalize Extension Ensures extension begins with "."

    Parameters

    • ext: any

      the extension to be normalized.

    Returns string

on

  • on(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

once

  • once(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

register

  • Register Registers a template with Mustr.

    Parameters

    • name: string
    • template: string

      the template name, path or static string to be registered.

    • Optional partials: string | string[] | BeforeRender
    • Optional beforeRender: BeforeRender

    Returns IMustr

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: Function): this
  • Parameters

    • event: string | symbol
    • listener: Function

    Returns this

render

  • render(path: string | ITemplate, body?: string, data?: object, partials?: object): void
  • Render Renders the template and writes out result.

    Parameters

    • path: string | ITemplate

      the path to render the template to.

    • Optional body: string

      the body or template string to be used in compiling.

    • Optional data: object

      the data to use when compiling body for render.

      • [key: string]: any
    • Optional partials: object
      • [key: string]: any

    Returns void

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

transformCase

  • transformCase(str: string, to: string): string
  • Transform To Transforms a string to the desired casing.

    Parameters

    • str: string

      the string to be transformed.

    • to: string

      the casing to be transformed to using lodash.

    Returns string

Private tryRequire

  • tryRequire(path: string): any
  • Try Require Tries to require a module logging error if failed.

    Parameters

    • path: string

      the module path to be required.

    Returns any

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc