Docma uses Dust.js as the template engine; which is also globally accessible within the template (web app).
As well as the Dust.js built-in filters, Docma includes pre-defined filters for ease of use.
Input | Filter | Description |
---|---|---|
String |
h |
HTML encode. |
String |
s |
Turn off automatic HTML encoding |
String |
j |
Javascript string encode |
String |
u |
encodeURI |
String |
uc |
encodeURIComponent |
Object |
js |
JSON.stringify |
String |
jp |
JSON.parse |
Input | Filter | Description |
---|---|---|
String |
$pt |
Converts ticks to HTML code tags. Also available as docma.utils.parseTicks(string)
|
String |
$pnl |
Converts new lines to HTML paragraphs. Also available as docma.utils.parseNewLines(string)
|
String |
$pl |
Converts JSDoc @link directives to HTML anchor tags.Also available as docma.utils.parseLinks(string)
|
String |
$tl |
Removes leading spaces and dashes. Also available as docma.utils.trimLeft(string)
|
String |
$p |
Applies $tl|$pnl|$pt|$pl filters combined.Also available as docma.utils.parse(string)
|
String |
$nt |
Normalizes the number of spaces/tabs to multiples of 2 spaces, in the beginning of each line. Also available as docma.utils.normalizeTabs(string)
|
Object (symbol) |
$desc |
Parses and returns the (class description or) description of the documentation symbol. |
Object (param) |
$def |
Returns the default value of the parameter or symbol. |
Object (symbol) |
$val |
Returns the value of the symbol (if any). |
Object (symbol) |
$id |
Returns a readable id for the symbol. Useful for anchor bookmarks. e.g. <a href="#{.|$id}">{longname}</a>
|
You can also create your own custom filters using either the dust
object or shorthand methods defined by Docma Web.
// filter that adds parenthesis if the symbol is a method.
docma.addFilter('$parenths', function (symbol) {
return docma.utils.isMethod(symbol)
? symbol.longname + '()'
: symbol.longname;
});
{#documentation}
<h3>{.|$parenths}</h3>
<p>{description|s}</p>
{/documentation}