Template Functions
Compozy leverages popular JavaScript libraries to provide a comprehensive set of utility functions for data manipulation within your template expressions.
Introduction
Instead of reinventing the wheel, Compozy provides direct access to well-established JavaScript utility libraries within your template expressions:
- Lodash - For general utility functions (
_
) - Voca - For string manipulation (
v
) - Day.js - For date operations (
dayjs
) - Numeral.js - For number formatting (
numeral
)
These libraries are available globally in your template expressions, providing battle-tested and well-documented functionality. Need additional libraries? You can add custom dependencies through the $
namespace (e.g., $.math
, $.decimal
). Check out Custom Dependencies to learn more.
Built-in Libraries
Lodash Functions
Available through the _
global variable.
Voca Functions
Available through the v
global variable.
Day.js Functions
Available through the dayjs
global variable.
Numeral.js Functions
Available through the numeral
global variable.
Best Practices
Library Documentation
Each library provides extensive documentation for their functions:
- Lodash Documentation - Complete reference of all available Lodash functions
- Voca Documentation - Comprehensive guide to string manipulation functions
- Day.js Documentation - Date manipulation and formatting guide
- Numeral.js Documentation - Number formatting guide
Function Categories
For convenience, we’ve organized common operations into categories:
- String Functions - String manipulation examples using Voca
- Array Functions - Array operations using Lodash
- Object Functions - Object manipulation with Lodash
- Date Functions - Date operations using Day.js