summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ste/STECore.php7
-rw-r--r--tests/test.php9
-rw-r--r--tests/test_autoescape/code.php7
3 files changed, 16 insertions, 7 deletions
diff --git a/src/ste/STECore.php b/src/ste/STECore.php
index 4637aaa..91a96ca 100644
--- a/src/ste/STECore.php
+++ b/src/ste/STECore.php
@@ -16,7 +16,7 @@ class STECore {
private $tags;
private $storage_access;
private $cur_tpl_dir;
- public $escape_method = self::ESCAPE_NONE;
+ private $escape_method = self::ESCAPE_NONE;
public $scope;
/*
@@ -39,9 +39,12 @@ class STECore {
*
* Parameters:
* $storage_access - An Instance of a <StorageAccess> implementation.
+ * $escape_method - One of the ESCAPE_* constants
*/
- public function __construct($storage_access) {
+ public function __construct($storage_access, $escape_method=self::ESCAPE_NONE) {
$this->storage_access = $storage_access;
+ $this->escape_method = $escape_method;
+
$this->cur_tpl_dir = "/";
STEStandardLibrary::_register_lib($this);
$this->blockorder = array();
diff --git a/tests/test.php b/tests/test.php
index ed45d3e..f051d94 100644
--- a/tests/test.php
+++ b/tests/test.php
@@ -1,10 +1,15 @@
<?php
require(dirname(__FILE__) . "/../steloader.php");
-require("code.php");
use \kch42\ste;
+$ste_initializer = function($sa) {
+ return new ste\STECore($sa);
+};
+
+require("code.php");
+
class TestStorage implements ste\StorageAccess {
public function load($tpl, &$mode) {
$mode = ste\StorageAccess::MODE_SOURCE;
@@ -20,7 +25,7 @@ class TestStorage implements ste\StorageAccess {
}
}
-$ste = new ste\STECore(new TestStorage());
+$ste = $ste_initializer(new TestStorage());
$ste->mute_runtime_errors = false;
test_func($ste);
echo $ste->exectemplate("test.tpl");
diff --git a/tests/test_autoescape/code.php b/tests/test_autoescape/code.php
index 4f7c998..9f73700 100644
--- a/tests/test_autoescape/code.php
+++ b/tests/test_autoescape/code.php
@@ -2,13 +2,14 @@
use kch42\ste\STECore;
+$ste_initializer = function($sa) {
+ return new STECore($sa, STECore::ESCAPE_HTML);
+};
+
function test_func($ste) {
$ste->vars['test'] = 'foo"&<bar>';
$ste->register_tag('echoarg', function ($ste, $params, $sub) {
return $params['echo'];
});
-
- // Autoescaping enabled by default
- $ste->escape_method = STECore::ESCAPE_HTML;
}