Utils Class
Utilities Class
Item Index
Methods
escapeHTML
-
html
Escapes HTML characters in html.
Parameters:
-
html
StringString to escape.
Returns:
Escaped string.
fixType
-
t
Takes a type string and converts it to a "First letter upper cased" type. e.g. (string -> String, object -> Object)
Parameters:
-
t
StringThe type string to convert
Returns:
The fixed string
getDirs
-
baseDir
-
ignore
Walks the tree from this dir and returns all the subdirs
Returns:
The array of directories..
getLayouts
-
dir
Like getPages()
, but returns only the files under the layout/
subdirectory
of the specified dir.
Parameters:
-
dir
StringDirectory path.
Returns:
Mapping of layout names to layout content.
getPage
-
pagePath
Loads and returns the content of the specified page file.
Parameters:
-
pagePath
StringPath to a single
.handlebars
page.
Returns:
Page content, or null
if not found.
getPages
-
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:
-
dir
StringDirectory path.
Returns:
Mapping of page names to page content.
getPartials
-
dir
Like getPages()
, but returns only the files under the partial/
subdirectory
of the specified dir.
Parameters:
-
dir
StringDirectory path.
Returns:
Mapping of partial names to partial content.
getProjectData
-
[directory=process.cwd()]
Walk the directory tree to locate the yuidoc.json file.
Parameters:
-
[directory=process.cwd()]
Path optionalThe directory to start from
prepare
-
inDir
-
options
-
callback
Mix/merge/munge data into the template.
unindent
-
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.
Parameters:
-
content
StringText to unindent.
Returns:
Unindented text.
validatePaths
-
paths
-
[ignore=false]
Make sure all the paths passed are directories and that they are not in the ignore list.
webpath
-
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
Returns:
The joined and normalized url