dev-master
9999999-dev
The Requires
- ext-blitz *
The Development Requires
1.1.1
1.1.1.0
The Requires
- ext-blitz *
The Development Requires
Wallogit.com
2017 © Pedro Peláez
A small extension to Blitz template engine, adding template inheritance and auto-escaping., (*1)
article.tpl:, (*2)
<article>text</article>
layout.tpl:, (*3)
<header/>
{{ raw(content) }}
<footer/>
PHP code:, (*4)
$view = new View("article.tpl");
$view->extend("layout.tpl");
echo $view->parse();
The output:, (*5)
<header/> <article>text</article> <footer/>
Initialize view:, (*6)
$view = new \SaferBlitz\View;
In template:, (*7)
{{ $some_variable }}
In controller:, (*8)
$view->set(["some_variable" => "some nasty XSS attempt: \"><script>alert(\"XSS\");</script>"]); $view->display();
Result:, (*9)
some nasty XSS attempt: "><script>alert("XSS");</script>
To output variable unescaped, use raw($var) template API:, (*10)
{{ raw($trusted_variable) }}
If anyone appears to be interested in this project, I will probably add proper escape methods to escape attributes, CSS, JS. For now, this is out of my personal scope of use though., (*11)