Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mustr

Hierarchy

  • EventEmitter
    • Mustr

Implements

Index

Constructors

constructor

Properties

components

components: IComponents

cwd

cwd: string = process.cwd()

log

log: ILogger

options

options: IMustrOptions

outputPath

outputPath: string

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

Private addPartials

  • addPartials(template: ITemplate, ...args: any[]): void
  • Add Partials

    Parameters

    • template: ITemplate

      the template to add partials to.

    • Rest ...args: any[]

      the list of partials to add.

    Returns void

configure

  • Configure Configures template for output.

    Parameters

    • name: string

      the name of the template to load.

    • output: string

      the output name/path to use when rendering.

    • Optional options: IRegisterConfig

      the optional config for the template.

    Returns ITemplate

emit

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

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

    Returns boolean

eventNames

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

getMaxListeners

  • getMaxListeners(): number
  • Returns number

Private getPartial

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

init

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

    Parameters

    • Optional force: boolean

      when true forces init.

    Returns void

inject

  • inject(filename: string | IInject, find?: string | RegExp | NodeCallback, strategy?: "before" | "after" | "first" | "last" | "replace", insert?: string | string[], done?: NodeCallback): void
  • 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 | IInject

      the file name to inject into.

    • Optional find: string | RegExp | NodeCallback

      the string or expression to match.

    • Optional strategy: "before" | "after" | "first" | "last" | "replace"

      insert on before, after, replace, first or last when matched.

    • Optional insert: string | string[]

      the value or callback for injecting upon match.

    • Optional done: NodeCallback

      the callback on file written.

    Returns 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

Private 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

registerGroup

  • registerGroup(name: string | IGroupOptions, ...args: any[]): void
  • Register Group Registers a group of templates which will output to the specified directory. Often a component may have several files such as styles helpers, interfaces or maybe actions for react. This makes it easy to output all the files needed at once, hence a "component".

    Parameters

    • name: string | IGroupOptions

      the name of the component regsiter.

    • Rest ...args: any[]

      array of template names or csv params.

    Returns void

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 Renders the requested template.

    Parameters

    • name: string | ITemplate

      the name of the template to render.

    • Optional output: string | IRegisterConfig | NodeCallback | boolean

      the output path/name to render the template as.

    • Optional options: IRegisterConfig | NodeCallback | boolean

      the configuration and metadata object.

    • Optional force: boolean | NodeCallback

      forces overwriting existing file.

    • Optional done: NodeCallback

      Node style callback with err and rendered template.

    • Optional group: string

    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 truncate

  • truncate(str: any, max: any): any
  • Truncate Nothing special, cheesy truncation...move along.

    Parameters

    • str: any

      the string to be truncated.

    • max: any

      the max len before truncating.

    Returns any

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