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.
Parameters:
Name | Type | Description |
---|---|---|
helperName |
string
|
helper name, it can be a http url, file path or helper name. |
evalHelperSync(helperName) → {Helper}
Sync to eval the helper by name.
Parameters:
Name | Type | Description |
---|---|---|
helperName |
string
|
helper name, it can be a http url, file path or helper name. |
(async) evalSnippet(snippetName) → {Promise.<Rewriter>}
Async to eval the snippet by name.
Parameters:
Name | Type | Description |
---|---|---|
snippetName |
string
|
snippet name, it can be a http url, file path or short snippet name. |
evalSnippetSync(snippetName) → {Rewriter}
Sync to eval the snippet by name.
Parameters:
Name | Type | Description |
---|---|---|
snippetName |
string
|
snippet name, it can be a http url, file path or short snippet name. |
(async) glob(filePattern) → {Promise.<Array.<string>>}
Async to glob matching files.
Parameters:
Name | Type | Description |
---|---|---|
filePattern |
string
|
file pattern |
Returns:
- Type:
-
Promise.<Array.<string>>
matching files
globSync(filePattern) → {Array.<string>}
Sync to glob matching files.
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.
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.
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.
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.
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.