Global

Methods

encode(str) → {string}

Encode html string, leave only javascript code, replace other html code with whitespace.
Source:
Parameters:
Name Type Description
str string html string
Returns:
Type:
string
encoded string

encode(str) → {string}

Encode erb string, leave only javascript code, replace other erb code with whitespace.
Source:
Parameters:
Name Type Description
str string html string
Returns:
Type:
string
encoded string

(async) evalHelper(helperName) → {Promise.<Helper>}

Async to eval the helper by name.
Source:
Parameters:
Name Type Description
helperName string helper name, it can be a http url, file path or helper name.
Returns:
Type:
Promise.<Helper>
a Helper object

evalHelperSync(helperName) → {Helper}

Sync to eval the helper by name.
Source:
Parameters:
Name Type Description
helperName string helper name, it can be a http url, file path or helper name.
Returns:
Type:
Helper
a Helper object

(async) evalSnippet(snippetName) → {Promise.<Rewriter>}

Async to eval the snippet by name.
Source:
Parameters:
Name Type Description
snippetName string snippet name, it can be a http url, file path or short snippet name.
Returns:
Type:
Promise.<Rewriter>
a Rewriter object

evalSnippetSync(snippetName) → {Rewriter}

Sync to eval the snippet by name.
Source:
Parameters:
Name Type Description
snippetName string snippet name, it can be a http url, file path or short snippet name.
Returns:
Type:
Rewriter
a Rewriter object

(async) glob(filePattern) → {Promise.<Array.<string>>}

Async to glob matching files.
Source:
Parameters:
Name Type Description
filePattern string file pattern
Returns:
Type:
Promise.<Array.<string>>
matching files

globSync(filePattern) → {Array.<string>}

Sync to glob matching files.
Source:
Parameters:
Name Type Description
filePattern string file pattern
Returns:
Type:
Array.<string>
matching files

(async) isValidFile(path) → {Promise.<boolean>}

Async to check if it is a valid file path.
Source:
Parameters:
Name Type Description
path string file path
Returns:
Type:
Promise.<boolean>
gets true it is a valid file

isValidFileSync(path) → {boolean}

Sync to check if it is a valid file path.
Source:
Parameters:
Name Type Description
path string file path
Returns:
Type:
boolean
gets true it is a valid file

(async) loadSnippet(snippetName, insertRequire) → {Promise.<string>}

Sync to load snippet by snippet name.
Source:
Parameters:
Name Type Default Description
snippetName string snippet name, it can be a http url, file path or short snippet name.
insertRequire boolean true insert require statement or not
Throws:
snippet not found
Type
SnippetNotFoundError
Returns:
Type:
Promise.<string>
snippet helper content

loadSnippetSync(snippetName, insertRequire) → {string}

Sync to load snippet by snippet name.
Source:
Parameters:
Name Type Default Description
snippetName string snippet name, it can be a http url, file path or short snippet name.
insertRequire boolean true insert require statement or not
Throws:
snippet not found
Type
SnippetNotFoundError
Returns:
Type:
string
snippet helper content

rewriteSnippetToAsyncVersion()

Rewrite javascript snippet to async version.
Source:

rewriteSnippetToSyncVersion()

Rewrite javascript snippet to sync version.
Source: