Filter Strings is a Grav plugin that utilizes Stringy to manipulate strings in twig templates.
Filter Strings can be installed in two different ways; Our Grav Package Manager (GPM) install method is the easiest and most reliable method. However, the plugin can also be installed via a zip file.
Utilizing the system terminal the plugin can be installed from root. In the system terminal navigate (change directories) to the root of the Grav project. Type in the following command:
bin/gpm install filter-strings
The command will install the plugin under the /user/plugins
directory in Grav.
To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins
. Then, rename the folder to filter-strings
. You can find these files either on GitHub or via GetGrav.org.
You should now have all the plugin files under
/your/site/grav/user/plugins/filter-strings
In order to use the Filter Strings plugin it needs to be enabled in the configuration files. By default Filter Strings is enabled. To call the plugin from twig use a pipe |
and a function name (List of functions can be found in Stringy) followed by an underscore and string (eg: SomeStringVariable|titleize_string
)
Note: Currently only Stringy functions that modify a string without arguments work. Other modifiers have not been tested.