diff --git a/NEWS b/NEWS
index 92b1bca4..6cf9618e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+ - added strip variable modifier, updated docs (Monte)
- fixed access to $smarty.x variables as arrays. (Andrei)
- fixed errors with example setup docs (Monte, Matthew
Hagerty)
diff --git a/docs/designers.sgml b/docs/designers.sgml
index 8b24167b..0a3cacc9 100644
--- a/docs/designers.sgml
+++ b/docs/designers.sgml
@@ -1000,6 +1000,34 @@ OUTPUT:
23.5787446
23.58
24
+
+
+
+ strip
+
+ This replaces all repeated spaces, newlines and tabs with a single
+ space, or with a supplied string.
+
+
+ Note
+
+ If you want to strip blocks of template text, use the strip function.
+
+
+
+strip
+
+{$articleTitle}
+{$articleTitle|strip}
+{$articleTitle|strip:" "}
+
+OUTPUT:
+
+Grandmother of
+eight makes hole in one
+Grandmother of eight makes hole in one
+Grandmother of eight makes hole in one
@@ -2539,20 +2567,27 @@ e-mail: jane@mydomain.com<p>
strip
- Many times web designers
- run into the issue where white space and carriage returns
- affect the output of the rendered HTML (browser "features"), so you
- must run all your tags together in the template to get the
- desired results. This usually ends up in unreadable or
+ Many times web designers run into the issue where white space and
+ carriage returns affect the output of the rendered HTML (browser
+ "features"), so you must run all your tags together in the template
+ to get the desired results. This usually ends up in unreadable or
unmanagable templates.
- Anything within {strip}{/strip} tags in Smarty are stripped of
- the extra spaces or carriage returns at the beginnings and
- ends of the lines before they are displayed.
- This way you can keep your templates readable, and not worry
- about extra white space causing problems.
+ Anything within {strip}{/strip} tags in Smarty are stripped of the
+ extra spaces or carriage returns at the beginnings and ends of the
+ lines before they are displayed. This way you can keep your
+ templates readable, and not worry about extra white space causing
+ problems.
+
+ Technical Note
+
+ {strip}{/strip} does not affect the contents of template variables.
+ See the strip modifier
+ function.
+
+ strip tags
diff --git a/libs/plugins/modifier.strip.php b/libs/plugins/modifier.strip.php
new file mode 100644
index 00000000..8182f833
--- /dev/null
+++ b/libs/plugins/modifier.strip.php
@@ -0,0 +1,23 @@
+
+ * Version: 1.0
+ * Date: September 25th, 2002
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_strip($text, $replace = ' ')
+{
+ return preg_replace('!\s+!', $replace, $text);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/plugins/modifier.strip.php b/plugins/modifier.strip.php
new file mode 100644
index 00000000..8182f833
--- /dev/null
+++ b/plugins/modifier.strip.php
@@ -0,0 +1,23 @@
+
+ * Version: 1.0
+ * Date: September 25th, 2002
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_strip($text, $replace = ' ')
+{
+ return preg_replace('!\s+!', $replace, $text);
+}
+
+/* vim: set expandtab: */
+
+?>