Complete Feature Reference
All available Twig filters, functions, tests, and tags in pieceofcake2/twig-view.
Quick Navigation
- Filters - Transform values:
{{ value|filter }} - Functions - Generate values:
{{ function() }} - Tests - Check conditions:
{% if value is test %} - Tags - Control structures:
{% tag %} - CakePHP Helpers - Access helpers:
{{ helper.method() }}
Filters
Twig 3.x Built-in Filters
Reference: https://twig.symfony.com/doc/3.x/filters/index.html
absbatchcapitalizecolumnconvert_encodingcountry_namecurrency_namecurrency_symboldata_uridatedate_modifydefaultescape(alias:e)filterfindfirstformatformat_currencyformat_dateformat_datetimeformat_numberformat_timehtml_to_markdowninline_cssinky_to_htmljoinjson_encodekeyslanguage_namelastlengthlocale_namelowermapmarkdown_to_htmlmergenl2brnumber_formatpluralrawreducereplacereverseroundshufflesingularsliceslugsortspacelesssplitstriptagstimezone_nametitletrimuupperurl_encode
String Filters (from cakephp/twig-view)
Implemented:
tokenizeinsertclean_insert(alias:cleanInsert)wrapwrap_block(alias:wrapBlock)word_wrap(alias:wordWrap)highlighttailtruncateexcerptto_list(alias:toList)strip_links(alias:stripLinks)
Not Implemented:
substr- ❌ Use Twig's built-inslicefilter instead
Inflection Filters (from cakephp/twig-view)
Implemented:
pluralizesingularizecamelizeunderscorehumanizetableizeclassifyvariableslug
Number Filters (from cakephp/twig-view)
Implemented:
to_readable_sizeto_percentageformat_delta(alias:formatDelta)currencyprecision
Not Implemented:
number_format- ❌ Use Twig's built-innumber_formatorformat_numberfilter instead
Utility Filters (from cakephp/twig-view)
Not Implemented:
utf8- ❌ Not a view concern, prepare data in controller with proper encodingascii- ❌ Not a view concern, prepare data in controller with proper encodinglow- ❌ Use Twig's built-inlowerfilter (kept in Legacy for backward compatibility)up- ❌ Use Twig's built-inupperfilter (kept in Legacy for backward compatibility)env- ❌ Not a view concern (kept in Legacy for backward compatibility)serialize- ❌ Not a view concern, prepare data in controllerunserialize- ❌ Not a view concern, prepare data in controllermd5- ❌ Not a view concern, prepare data in controllerbase64_encode- ❌ Not a view concern, prepare data in controllerbase64_decode- ❌ Not a view concern, prepare data in controllerstring- ❌ Not needed, Twig auto-converts with__toString()is_multibyte- ❌ Usemultibytetest instead:{% if text is multibyte %}
I18n Filters (pieceofcake2/twig-view original)
trans
CakePHP-based, Symfony-like interface
Legacy Filters (cakephp/legacy-twig-view:<2 - ⚠️ DEPRECATED)
Not Implemented:
ago- ❌ Use{{ time.timeAgoInWords(date) }}size- ❌ Useto_readable_sizep- ❌ Useprecisioncurr- ❌ Usecurrencypct- ❌ Useto_percentagelow- ❌ Use Twig'slowerup- ❌ Use Twig'supperdebug- ❌ Use Twig'sdump()pr- ❌ Use Twig'sdump()env- ❌ Pass from controller
Functions
Twig 3.x Built-in Functions
Reference: https://twig.symfony.com/doc/3.x/functions/index.html
attributeblockconstantcountry_namescountry_timezonescurrency_namescycledatedumpenumenum_caseshtml_classeshtml_cvaincludelanguage_nameslocale_namesmaxminparentrandomrangescript_namessourcetemplate_from_stringtimezone_names
I18n Functions (pieceofcake2/twig-view original)
Implemented:
____d__n__x
Number Functions (from cakephp/twig-view)
Not Implemented:
default_currency- ❌ Use{{ number.defaultCurrency() }}instead
View Functions (from cakephp/twig-view)
Implemented:
elementfetch
Not Implemented (from cakephp/twig-view ArraysExtension):
in_array- ❌ Use Twig'sinoperator:{% if 'foo' in array %}explode- ❌ Use Twig'ssplitfilter:{{ "a,b"|split(',') }}array- ❌ Not a view concern, prepare data in controllerarray_push- ❌ Use Twig'smergefilter:{{ array|merge(['new']) }}array_prev- ❌ Not a view concern, useloopvariable in templatesarray_next- ❌ Not a view concern, useloopvariable in templatesarray_current- ❌ Not a view concern, useloopvariable in templates
Not Implemented (from cakephp/twig-view TimeExtension):
time- ❌ Use Twig's built-indatefunctiontimezones- ❌ Not a view concern, prepare data in controller
Not Implemented (from cakephp/twig-view UtilsExtension):
uuid- ❌ Not a view concern, generate in controller/model
Routing Functions (pieceofcake2/twig-view original)
urlpath
Tests
Twig 3.x Built-in Tests
Reference: https://twig.symfony.com/doc/3.x/tests/index.html
Custom Tests (from cakephp/twig-view)
Implemented:
multibyte
Tags
Twig 3.x Built-in Tags
Reference: https://twig.symfony.com/doc/3.x/tags/index.html
applyautoescapeblockcachedeprecateddoembedextendsflushforfromguardifimportincludemacrosandboxsettypesuseverbatimwith
Custom Tags (from cakephp/twig-view)
Implemented:
{% layout 'name' %}- Set layout
Custom Tags (pieceofcake2/twig-view original)
Implemented:
{% trans %}...{% endtrans %}- Translation block (CakePHP-based, Symfony-like)
Legacy (cakephp/legacy-twig-view:<2)
Not Implemented:
{% element 'name' %}- ❌ Useelement()function instead
CakePHP Helpers
CakePHP Helpers must be enabled in your controller to be available in Twig templates.
Enable in controller: public $helpers = ['Html', 'Form', 'Time', 'Number', 'Text', 'Session', 'Paginator'];
Naming: Helper class names are converted to lowercase (e.g., HtmlHelper::link() → {{ html.link() }}, MyCustomHelper::method() → {{ mycustom.method() }})
FlashHelper
Flash message rendering.
flash.render(key = 'flash', options = {})- Render flash message
FormHelper
Form creation and input generation.
form.create(model = null, options = {})- Create opening form tagform.end(options = null, secureAttributes = {})- Close formform.input(fieldName, options = {})- Generate input fieldform.inputs(fields = null, blacklist = null, options = {})- Generate multiple inputsform.label(fieldName, text = null, options = {})- Create label elementform.text(name, options = {})- Create text inputform.password(fieldName, options = {})- Create password inputform.hidden(fieldName, options = {})- Create hidden inputform.textarea(fieldName, options = {})- Create textareaform.checkbox(fieldName, options = {})- Create checkboxform.radio(fieldName, options, attributes = {})- Create radio buttonsform.select(fieldName, options, attributes = {})- Create select dropdownform.file(fieldName, options = {})- Create file upload inputform.submit(caption = null, options = {})- Create submit buttonform.button(title, options = {})- Create button elementform.postButton(title, url, options = {})- Create POST buttonform.postLink(title, url = null, options = {})- Create POST linkform.dateTime(fieldName, dateFormat = 'DMY', timeFormat = '12', attributes = {})- Create date/time selectsform.year(fieldName, minYear, maxYear, attributes)- Create year selectform.month(fieldName, attributes = {})- Create month selectform.day(fieldName, attributes = {})- Create day selectform.hour(fieldName, format24 = false, attributes = {})- Create hour selectform.minute(fieldName, attributes = {})- Create minute selectform.meridian(fieldName, attributes = {})- Create AM/PM select
HtmlHelper
HTML generation and markup creation.
html.charset(charset = null)- Meta tag for character encodinghtml.css(path, options = {})- Link to CSS stylesheet(s)html.meta(type, url = null, options = {})- Generate meta tagshtml.docType(type = 'xhtml-strict')- Return doctype taghtml.style(data, oneline = true)- Build CSS from arrayhtml.image(path, options = {})- Create image taghtml.link(title, url = null, options = {})- Generate HTML linkhtml.media(path, options)- Create audio/video taghtml.tag(tag, text, options)- Wrap text in HTML taghtml.div(class, text, options)- Create div elementhtml.para(class, text, options)- Create paragraph elementhtml.script(url, options)- Include JavaScript file(s)html.scriptBlock(code, options = {})- Generate script blockhtml.scriptStart(options = {})- Begin script bufferinghtml.scriptEnd()- End script bufferinghtml.nestedList(list, options = {}, itemOptions = {}, tag = 'ul')- Build nested listhtml.tableHeaders(names, trOptions = null, thOptions = null)- Create table headershtml.tableCells(data, oddTrOptions = null, evenTrOptions = null, useCount = false, continueOddEven = true)- Create table cellshtml.url(url = null, full = false)- Generate URL
NumberHelper
Number formatting and conversion.
number.currency(number, currency = 'USD', options = {})- Format as currencynumber.defaultCurrency(currency)- Get/set default currencynumber.addFormat(formatName, options)- Add custom currency formatnumber.precision(number, precision = 3)- Format with decimal precisionnumber.toPercentage(number, precision = 2, options = {})- Convert to percentagenumber.fromReadableSize(size, default)- Convert "1 KB" to bytesnumber.toReadableSize(dataSize)- Format as "1 KB", "1 MB", etc.number.format(number, options = false)- Format number with optionsnumber.formatDelta(number, options = {})- Format signed number difference
PaginatorHelper
Pagination support.
paginator.options(options = {})- Set pagination optionspaginator.params(model = null)- Get pagination paramspaginator.param(key, model = null)- Get single pagination parampaginator.url(options = {}, asArray = false, model = null)- Generate pagination URLpaginator.defaultModel()- Get/set default modelpaginator.link(title, url = {}, options = {})- Generate pagination linkpaginator.prev(title = '<< Previous', options = {}, disabledTitle = null, disabledOptions = {})- Previous linkpaginator.next(title = 'Next >>', options = {}, disabledTitle = null, disabledOptions = {})- Next linkpaginator.sort(key, title = null, options = {})- Generate sort linkpaginator.sortDir(model = null, options = {})- Get sort directionpaginator.sortKey(model = null, options = {})- Get sort keypaginator.numbers(options = {})- Generate page numberspaginator.first(first = '<< first', options = {})- First page linkpaginator.last(last = 'last >>', options = {})- Last page linkpaginator.counter(options = {})- Page counter (e.g., "1-20 of 100")paginator.hasNext(model = null)- Check if next page existspaginator.hasPrev(model = null)- Check if previous page existspaginator.hasPage(model = null, page = 1)- Check if page exists
See Using CakePHP Helpers for detailed usage guide.
See Also
- Installation - Setup guide
- Quick Start - Getting started
- Using Helpers - CakePHP Helper integration
- Configuration - Advanced configuration options
- Extensions - Popular Twig extensions
