Libraries API¶
registerLibrary¶
Register a library — a named bundle of filters, tags, and helpers.
activateLibrary¶
Activate a library so its filters and tags become available.
Built-in libraries (humanize, cache, lorem, markdown, i18n) are auto-activated on import.
unregisterLibrary¶
hasLibrary¶
getLibrary¶
Retrieve a library by name.
getLibraryNames¶
registerLibraryFromPath¶
Load a library from a JavaScript file on disk. The file must export { tags, filters, helpers }.
Built-in Libraries¶
humanize¶
Provides natural formatting filters: intcomma, intword, ordinal, naturalday, naturaltime.
| Filter | Description |
|--------|-------------|
| intcomma | 1234567 → 1,234,567 |
| intword | 1234567 → 1.2M |
| ordinal | 1 → 1st, 2 → 2nd |
| naturalday | Format dates as "today", "yesterday" |
| naturaltime | Format times as "just now", "2 hours ago" |
| ordinal | Convert numbers to ordinal (1st, 2nd, 3rd) |
cache¶
Provides {% cache timeout key %}...{% endcache %} tag for caching template fragments.
lorem¶
Provides {% lorem count random_words %} tag and lorem filter for placeholder text.
markdown¶
Provides markdown filter for Markdown→HTML conversion.
i18n¶
Provides {% trans %}, {% blocktrans %}, {% language %} tags and translation functions.