utils Module
Utilities modules
Direct Members
Index
Methods:
escapeHTML
(
-
html
)
String
-
html
Escapes HTML characters in html.
parameters:
-
htmlStringString to escape.
returns:
Escaped string.
safetrim
(
-
str
)
String
-
str
Trim in safe mode
parameters:
-
strString
returns:
trimed string or other types if invalid
unindent
(
-
content
)
String
-
content
Normalizes the initial indentation of the given content so that the first line is unindented, and all other lines are unindented to the same degree as the first line. So if the first line has four spaces at the beginning, then all lines will be unindented four spaces. Ported from Selleck
parameters:
-
contentStringText to unindent.
returns:
Unindented text.
filterFileName
(
-
f
)
String
-
f
Normalizes a file path to a writable filename:
var path = 'lib/file.js'; returns 'lib_file.js';
parameters:
-
fStringThe filename to normalize
returns:
The filtered file path
getLayouts
(
-
dir
)
Object
-
dir
Like getPages(), but returns only the files under the layout/ subdirectory
of the specified dir.
parameters:
-
dirStringDirectory path.
returns:
Mapping of layout names to layout content.
getPage
(
-
p
)
String | null
-
p
Loads and returns the content of the specified page file.
parameters:
-
pStringPath to a single.handlebarspage.
returns:
Page content, or null if not found.
getPages
(
-
dir
)
Object
-
dir
Loads pages (files with a .handlebars extension) in the specified directory and
returns an object containing a mapping of page names (the part of the filename)
preceding the .handlebars extension) to page content.
parameters:
-
dirStringDirectory path.
returns:
Mapping of page names to page content.
getPartials
(
-
dir
)
Object
-
dir
Like getPages(), but returns only the files under the partial/ subdirectory
of the specified dir.
parameters:
-
dirStringDirectory path.
returns:
Mapping of partial names to partial content.
prepare
(
-
inDir
-
options
-
callback
)
-
inDir -
options -
callback
Mix/merge/munge data into the template.
parameters:
-
inDirStringThe starting directory -
optionsObjectTheoptionsfor the meta data. -
callbackcallbackThe callback to excecute when complete-
errError -
optionsObjectMerged options.
-
fixType
(
-
t
)
String
-
t
Takes a type string and converts it to a "First letter upper cased" type.
e.g. (string -> String, object -> Object)
parameters:
-
tStringThe type string to convert
returns:
The fixed string
webpath
(
-
url
)
String
-
url
Produces a normalized web path by joining all the parts and normalizing the filesystem-like path into web compatible url. Supports relative and absolute paths. Courtesy of Mojito's utils
parameters:
-
urlArray | Stringthe list of parts to be joined and normalized
returns:
The joined and normalized url
localize
(
-
str
-
lang
)
String
-
str -
lang
Localize the string via current Y.options
parameters:
-
strStringthe original string that you want to input -
langStringthe language
returns:
localized string from the param str
markdownLink
(
-
str
)
String
-
str
convert string to markdown link
parameters:
-
strStringThe original string that you want to input
returns:
marked string from the param str
buildFileTree
(
-
files
)
Object
-
files
build file tree object
parameters:
-
filesArray
returns: