aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/docs/api/extending/modifiers.md
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/smarty/smarty/docs/api/extending/modifiers.md')
-rw-r--r--vendor/smarty/smarty/docs/api/extending/modifiers.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/smarty/smarty/docs/api/extending/modifiers.md b/vendor/smarty/smarty/docs/api/extending/modifiers.md
new file mode 100644
index 000000000..78540cf97
--- /dev/null
+++ b/vendor/smarty/smarty/docs/api/extending/modifiers.md
@@ -0,0 +1,27 @@
+# Custom modifiers
+
+Modifiers are little functions that are applied
+to a variable in the template before it is displayed or used in some
+other context. Smarty comes with a bunch of [modifiers](../../designers/language-modifiers/index.md), but you can
+easily add your own.
+
+In order to do so, you must write a function that accepts as its first parameter the value on which the
+modifier is to operate. The rest of the parameters are optional, depending on what kind of operation is to be performed.
+
+The modifier has to return the result of its processing.
+
+For example:
+```php
+<?php
+
+function smarty_modifier_substr($string, $offset, $length) {
+ return substr($string, $offset, $length);
+}
+
+$smarty->registerPlugin(Smarty\Smarty::PLUGIN_MODIFIER, 'substr', 'smarty_modifier_substr');
+```
+
+You can now use this in your templates as follows:
+```smarty
+{$applicationName|substr:0:20}
+```