diff options
-rw-r--r-- | docu/language_definition.html | 7 | ||||
-rw-r--r-- | stupid_template_engine.php | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/docu/language_definition.html b/docu/language_definition.html index e311907..2c809bc 100644 --- a/docu/language_definition.html +++ b/docu/language_definition.html @@ -113,7 +113,7 @@ Just like their XML counterparts, they can wrap other elements (<code><ste:foo>bar<ste:baz>herpdederp</ste:baz></ste:foo></code>) or can be self-closing (<code><ste:foo /></code>). And they can have additional parameters (or "attributes", using the XML terminology): <code><ste:foo bar="baz" /></code> </p> - <p>A Tag is wrapped in <code><</code> and <code>></code>. The tag's name always start with <code>ste:</code> and can then consist of letters, numbers and underscores (Regex: <code>[a-zA-Z0-9_]+</code>).<p> + <p>A Tag is wrapped in <code><</code> and <code>></code>. The tag's name always start with <code>ste:</code> and can then consist of letters, numbers and underscores (Regex: <code>[a-zA-Z0-9_]+</code>).</p> <p>If the tag is self-closing, the last char is a <code>/</code> (e.g.: <code><ste:foo /></code>).</p> <p>If the tag is a closing one, the first char is a <code>/</code>. An opening Tag does not have a <code>/</code>.An example of an opening-closing Tag pair wrapping the text <code>bar</code>: <code><ste:foo>bar</ste:foo></code></p> <p> @@ -474,13 +474,16 @@ <h2 id="stdlib">Standard Library</h2> <p>The Standard Library contains some useful tags, which are not <a href="#builtin">builtin</a> but still always available.</p> <h3 id="stdlib_escape">ste:escape</h3> - <p>Escapes characters that are reserved for HTML (e.g. <code><</code>, <code>></code>, <code>"</code>, <code>&</code>). The text to escape is the tag's content. + <p>Escapes characters that are reserved for HTML (e.g. <code><</code>, <code>></code>, <code>"</code>, <code>&</code>). The text to escape is the tag's content.</p> <p> Example:<br /> <code><pre><ste:escape>Foo & bar...</ste:escape></pre></code> Result:<br /> <code><pre>Foo &amp; bar...</pre></code> </p> + <p> + If the optional parameter <code>lines</code> is true (i.e. not empty), then additionally line breaks are converted to <code><br /></code>. + </p> <h3 id="stdlib_strlen">ste:strlen</h3> <p>Returns the length of then content.</p> diff --git a/stupid_template_engine.php b/stupid_template_engine.php index b231e12..81a7688 100644 --- a/stupid_template_engine.php +++ b/stupid_template_engine.php @@ -1360,7 +1360,10 @@ class STEStandardLibrary static public function escape($ste, $params, $sub) { - return htmlentities($sub($ste), ENT_QUOTES, "UTF-8"); + if($ste->evalbool($params["lines"])) + return nl2br(htmlspecialchars(str_replace("\r\n", "\n", $sub($ste)))); + else + return htmlspecialchars($sub($ste)); } static public function strlen($ste, $params, $sub) |