FOSSBilling uses Twig across themes, email templates, and PDFs. This page lists the project-specific and third-party filters and functions you can rely on while building against it.
FOSSBilling includes all default Twig filters , plus the Intl Extra Extension for internationalization and the Markdown Extra Extension for Markdown rendering.
Common bundled filters include:
Filter Description format_currencyFormat a number as currency, for example {{ 29.99 | format_currency('USD') }}. format_dateFormat a date using the configured locale and date format. format_datetimeFormat a date and time using the configured locale and time zone. markdown_to_htmlConvert Markdown to HTML with FOSSBilling's safe CommonMark renderer.
Project-specific filters and functions are defined in these classes:
Filter Description transTranslate a string using FOSSBilling's translation system. timeagoShow how long ago a date was (e.g., "2 hours ago"). Accepts ISO 8601 format. daysleftShow days until a date. Accepts ISO 8601 format. period_titleDisplay a translated period title (e.g., 1M → "1 Month"). ip_country_nameShow the country name for an IP address. ip_country_codeShow the ISO 2-letter country code for an IP address.
Filter Description urlGenerate a URL for the current area, or pass area: 'admin' / area: 'client'. api_urlGenerate a URL for an API endpoint. Defaults to the current area; pass role: 'admin', role: 'client', or role: 'guest' when needed.
Filter Description asset_urlGet the URL for a theme asset. library_urlGet the URL for the library folder. mod_asset_urlGet the URL for a module asset. Use the asset path as the filtered value and the module name as the argument. script_tagGenerate an HTML <script> tag. stylesheet_tagGenerate an HTML <link> tag for CSS.
Filter Description file_sizeConvert bytes to a human-readable size (KB, MB, GB, etc.). hashHash a value. Defaults to xxh128; pass another PHP-supported algorithm if needed. truncateTruncate a string to a maximum length.
Function Description fb_apiRefer to JavaScript Wrapper for documentation. fb_api_formRefer to JavaScript Wrapper for documentation. fb_api_linkRefer to JavaScript Wrapper for documentation. render_widgetsRender widgets registered for a slot. svg_spriteRender the current theme's SVG icon sprite when available. has_permissionCheck whether the logged-in admin has a module permission. antispam_honeypotReturn the antispam honeypot configuration array.
{{ 29.99 | format_currency ( ' USD ' ) }} {# $29.99 #}
< a href = " {{ ' client/manage ' | url }} " > Manage </ a > {# client area #}
< a href = " {{ ' client/manage ' | url ( { area : ' admin ' } ) }} " > Manage </ a > {# admin area #}
{{ ' profile/update ' | api_url }}
{{ ' client/login ' | api_url ( role : ' guest ' ) }}
{{ product . description | markdown_to_html }}
{{ order . created_at | timeago }} {# 2 hours ago #}
{# Theme and module assets #}
< link rel = " stylesheet " href = " {{ ' css/theme.css ' | asset_url }} " >
< script src = " {{ ' js/widget.js ' | mod_asset_url (' Example ') }} " ></ script >
{# API form handled by Api/API.js #}
< form action = " {{ ' profile/update ' | api_url }} " {{ fb_api_form ( { message : ' Saved ' | trans } ) }}>
< input type = " text " name = " first_name " >
< button type = " submit " >{{ ' Save ' | trans }}</ button >
{# API link with a confirmation modal #}
< a href = " {{ ' client/delete ' | api_url ( query : { id : client . id }, role : ' admin ') }} "
{{ fb_api_link ( { modal : { type : ' confirm ' , title : ' Are you sure? ' | trans }, reload : true } ) }}>
See JavaScript API Wrapper for the data-fb-api options and CSRF behavior.