jswhetstone/twig-extension

A Twig extension providing convenience methods for context-specific HTML classes.

Maintainers

Package info

github.com/jswhetstone/twig-extension

pkg:composer/jswhetstone/twig-extension

Statistics

Installs: 2 374

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2014-06-18 19:03 UTC

This package is not auto-updated.

Last update: 2026-03-10 07:13:08 UTC


README

Some useful Twig functions for context-relevant class rendering.

{{ getActiveClass('/some/page') }}

Will return 'active' (without quotes) if the current URI contains the string specified. Good for rendering the active state on Bootstrap nav elements. Pass an empty string '' to check for root.

{{ getPageClasses() }}

Will return a class-ready string representation of the current URI. Each directory in the hierarchy is represented by a separate class. The root directory will return 'home' (without quotes).

license

This code is licensed under WTFPL