From 2a40eb87c8c679a25ddb42587a1934e02312cb4a Mon Sep 17 00:00:00 2001
From: Kevin Chabowski
, if parameter
lines is true.
* <ste:foo>bar<ste:baz>herpdederp</ste:baz></ste:foo>
) or can be self-closing (<ste:foo />
).
And they can have additional parameters (or "attributes", using the XML terminology): <ste:foo bar="baz" />
A Tag is wrapped in <
and >
. The tag's name always start with ste:
and can then consist of letters, numbers and underscores (Regex: [a-zA-Z0-9_]+
).
+
A Tag is wrapped in <
and >
. The tag's name always start with ste:
and can then consist of letters, numbers and underscores (Regex: [a-zA-Z0-9_]+
).
If the tag is self-closing, the last char is a /
(e.g.: <ste:foo />
).
If the tag is a closing one, the first char is a /
. An opening Tag does not have a /
.An example of an opening-closing Tag pair wrapping the text bar
: <ste:foo>bar</ste:foo>
@@ -474,13 +474,16 @@
The Standard Library contains some useful tags, which are not builtin but still always available.
Escapes characters that are reserved for HTML (e.g. <
, >
, "
, &
). The text to escape is the tag's content.
+
Escapes characters that are reserved for HTML (e.g. <
, >
, "
, &
). The text to escape is the tag's content.
Example:
Result:<ste:escape>Foo & bar...</ste:escape>
Foo & bar...
+ If the optional parameter lines
is true (i.e. not empty), then additionally line breaks are converted to <br />
.
+
Returns the length of then content.
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) -- cgit v1.2.3-70-g09d2