diff options
author | Kevin Chabowski <kevin@kch42.de> | 2014-05-24 14:45:13 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2014-05-24 14:45:13 +0200 |
commit | 3c51baa4167d5a68ff010dc81525b9340c5f1329 (patch) | |
tree | 87dbb507a20a8946f93ea8b26a1a784d5eec62ea | |
parent | 9f86139b7604ea782a35e09bf9d0c55154197051 (diff) | |
download | ste-3c51baa4167d5a68ff010dc81525b9340c5f1329.tar.gz ste-3c51baa4167d5a68ff010dc81525b9340c5f1329.tar.bz2 ste-3c51baa4167d5a68ff010dc81525b9340c5f1329.zip |
Moved code into src subfolder and fixed docu
-rw-r--r-- | composer.json | 20 | ||||
-rwxr-xr-x | mkdocu.sh | 2 | ||||
-rw-r--r-- | src/ASTNode.php (renamed from ASTNode.php) | 0 | ||||
-rw-r--r-- | src/BreakException.php (renamed from BreakException.php) | 0 | ||||
-rw-r--r-- | src/Calc.php (renamed from Calc.php) | 0 | ||||
-rw-r--r-- | src/CantLoadTemplate.php (renamed from CantLoadTemplate.php) | 3 | ||||
-rw-r--r-- | src/CantSaveTemplate.php (renamed from CantSaveTemplate.php) | 3 | ||||
-rw-r--r-- | src/ContinueException.php (renamed from ContinueException.php) | 0 | ||||
-rw-r--r-- | src/FatalRuntimeError.php (renamed from FatalRuntimeError.php) | 3 | ||||
-rw-r--r-- | src/FilesystemStorageAccess.php (renamed from FilesystemStorageAccess.php) | 7 | ||||
-rw-r--r-- | src/Misc.php (renamed from Misc.php) | 0 | ||||
-rw-r--r-- | src/ParseCompileError.php (renamed from ParseCompileError.php) | 0 | ||||
-rw-r--r-- | src/Parser.php (renamed from Parser.php) | 3 | ||||
-rw-r--r-- | src/RuntimeError.php (renamed from RuntimeError.php) | 3 | ||||
-rw-r--r-- | src/STECore.php (renamed from STECore.php) | 14 | ||||
-rw-r--r-- | src/STEStandardLibrary.php (renamed from STEStandardLibrary.php) | 0 | ||||
-rw-r--r-- | src/Scope.php (renamed from Scope.php) | 41 | ||||
-rw-r--r-- | src/StorageAccess.php (renamed from StorageAccess.php) | 3 | ||||
-rw-r--r-- | src/StorageAccessFailure.php (renamed from StorageAccessFailure.php) | 0 | ||||
-rw-r--r-- | src/TagNode.php (renamed from TagNode.php) | 0 | ||||
-rw-r--r-- | src/TextNode.php (renamed from TextNode.php) | 0 | ||||
-rw-r--r-- | src/Transcompiler.php (renamed from Transcompiler.php) | 3 | ||||
-rw-r--r-- | src/VarNotInScope.php (renamed from VarNotInScope.php) | 0 | ||||
-rw-r--r-- | src/VariableNode.php (renamed from VariableNode.php) | 0 | ||||
-rw-r--r-- | ste.php | 44 | ||||
-rw-r--r-- | steloader.php | 2 |
26 files changed, 84 insertions, 67 deletions
diff --git a/composer.json b/composer.json index b03a28e..59ef2a6 100644 --- a/composer.json +++ b/composer.json @@ -2,5 +2,23 @@ "name": "kch42/ste", "require": { "php": ">=5.3.0" - } + }, + "autoload": { + "psr-4": { + "kch42\\ste": "src/" + } + }, + "license": "MIT", + "authors": [ + { + "name": "Kevin Chabowski", + "email": "kevin@kch42.de", + "homepage": "http://kch42.de", + "role": "Developer" + } + ], + "description": "A compiling template engine with an XML-ish syntax", + "type": "library", + "keywords": ["templating"], + "homepage": "http://github.com/kch42/ste" }
\ No newline at end of file @@ -9,4 +9,4 @@ fi; fi test -d docu/nd || mkdir docu/nd test -d docu/nd_project_dir || mkdir docu/nd_project_dir -$ndpath -i . -o html docu/nd -p docu/nd_project_dir +$ndpath -i src -o html docu/nd -p docu/nd_project_dir diff --git a/ASTNode.php b/src/ASTNode.php index fc5d9cc..fc5d9cc 100644 --- a/ASTNode.php +++ b/src/ASTNode.php diff --git a/BreakException.php b/src/BreakException.php index 563bf53..563bf53 100644 --- a/BreakException.php +++ b/src/BreakException.php diff --git a/CantLoadTemplate.php b/src/CantLoadTemplate.php index 089eca8..82c7a9f 100644 --- a/CantLoadTemplate.php +++ b/src/CantLoadTemplate.php @@ -1,5 +1,8 @@ <?php +// File: CantLoadTemplate.php + +// Namespace: kch42\ste namespace kch42\ste; /* diff --git a/CantSaveTemplate.php b/src/CantSaveTemplate.php index 4b0a00d..1072ad1 100644 --- a/CantSaveTemplate.php +++ b/src/CantSaveTemplate.php @@ -1,5 +1,8 @@ <?php +// File: CantSaveTemplate.php + +// Namespace: kch42\ste namespace kch42\ste; /* diff --git a/ContinueException.php b/src/ContinueException.php index af79b1b..af79b1b 100644 --- a/ContinueException.php +++ b/src/ContinueException.php diff --git a/FatalRuntimeError.php b/src/FatalRuntimeError.php index 4873b1a..d5ca735 100644 --- a/FatalRuntimeError.php +++ b/src/FatalRuntimeError.php @@ -1,5 +1,8 @@ <?php +// File: FatalRuntimeError.php + +// Namespace: kch42\ste namespace kch42\ste; /* diff --git a/FilesystemStorageAccess.php b/src/FilesystemStorageAccess.php index 61ad452..ef29404 100644 --- a/FilesystemStorageAccess.php +++ b/src/FilesystemStorageAccess.php @@ -1,5 +1,8 @@ <?php +// File: FilesystemStorageAccess.php + +// Namespace: kch42\ste namespace kch42\ste; /* @@ -59,7 +62,9 @@ class FilesystemStorageAccess implements StorageAccess { public function save($tpl, $data, $mode) { $fn = (($mode == StorageAccess::MODE_SOURCE) ? $this->sourcedir : $this->transcompileddir) . "/" . $tpl . (($mode == StorageAccess::MODE_TRANSCOMPILED) ? ".php" : ""); @mkdir(dirname($fn), 0777, true); - if(file_put_contents($fn, "<?php \$transcompile_fx = $data; ?>") === false) { + if(file_put_contents($fn, "<?php + +// File: FilesystemStorageAccess.php \$transcompile_fx = $data; ?>") === false) { throw new CantSaveTemplate("Unable to save template."); } } diff --git a/ParseCompileError.php b/src/ParseCompileError.php index 5ee37c7..5ee37c7 100644 --- a/ParseCompileError.php +++ b/src/ParseCompileError.php diff --git a/Parser.php b/src/Parser.php index e3b8d07..7e93e47 100644 --- a/Parser.php +++ b/src/Parser.php @@ -1,5 +1,8 @@ <?php +// File: Parser.php + +// Namespace: kch42\ste namespace kch42\ste; /* diff --git a/RuntimeError.php b/src/RuntimeError.php index e9e9b89..ff3b26d 100644 --- a/RuntimeError.php +++ b/src/RuntimeError.php @@ -1,5 +1,8 @@ <?php +// File: RuntimeError.php + +// Namespace: kch42\ste namespace kch42\ste; /* diff --git a/STECore.php b/src/STECore.php index add09ad..c00bf67 100644 --- a/STECore.php +++ b/src/STECore.php @@ -1,5 +1,8 @@ <?php +// File: STECore.php + +// Namespace: kch42\ste namespace kch42\ste; /* @@ -161,6 +164,17 @@ class STECore { $this->scope->set_var_by_name($name, $val); } + /* + * Function: set_local_var + * Like <set_var_by_name>, but only sets the variable in the global scope (<set_var_by_name> will overwrite the variable in the parent scope, if it's defined there) . + * + * Parameters: + * $name - The variables name. + * $val - The new value. + * + * Throws: + * <RuntimeError> if the variable name can not be parsed (e.g. unbalanced brackets). + */ public function set_local_var($name, $val) { $this->scope->set_local_var($name, $val); } diff --git a/STEStandardLibrary.php b/src/STEStandardLibrary.php index 915b699..915b699 100644 --- a/STEStandardLibrary.php +++ b/src/STEStandardLibrary.php diff --git a/Scope.php b/src/Scope.php index 53566ed..0da2724 100644 --- a/Scope.php +++ b/src/Scope.php @@ -56,21 +56,6 @@ class Scope implements \ArrayAccess { throw new VarNotInScope(); } - /* - * Function: get_var_reference - * Get a reference to a template variable using a variable name. - * This can be used, if your custom tag takes a variable name as a parameter. - * - * Parameters: - * $name - The variables name. - * $create_if_not_exist - Should the variable be created, if it does not exist? Otherwise NULL will be returned, if the variable does not exist. - * - * Throws: - * <RuntimeError> if the variable name can not be parsed (e.g. unbalanced brackets). - * - * Returns: - * A Reference to the variable. - */ public function &get_var_reference($name, $create_if_not_exist, $localonly=false) { $nullref = NULL; @@ -118,18 +103,6 @@ class Scope implements \ArrayAccess { return $ref; } - /* - * Function: set_var_by_name - * Set a template variable by its name. - * This can be used, if your custom tag takes a variable name as a parameter. - * - * Parameters: - * $name - The variables name. - * $val - The new value. - * - * Throws: - * <RuntimeError> if the variable name can not be parsed (e.g. unbalanced brackets). - */ public function set_var_by_name($name, $val) { $ref = &$this->get_var_reference($name, true); $ref = $val; @@ -140,20 +113,6 @@ class Scope implements \ArrayAccess { $ref = $val; } - /* - * Function: get_var_by_name - * Get a template variable by its name. - * This can be used, if your custom tag takes a variable name as a parameter. - * - * Parameters: - * $name - The variables name. - * - * Throws: - * <RuntimeError> if the variable name can not be parsed (e.g. unbalanced brackets). - * - * Returns: - * The variables value. - */ public function get_var_by_name($name) { $ref = $this->get_var_reference($name, false); return $ref === NULL ? "" : $ref; diff --git a/StorageAccess.php b/src/StorageAccess.php index 2c4ba6c..81f7439 100644 --- a/StorageAccess.php +++ b/src/StorageAccess.php @@ -1,5 +1,8 @@ <?php +// File: StorageAccess.php + +// Namespace: kch42\ste namespace kch42\ste; /* diff --git a/StorageAccessFailure.php b/src/StorageAccessFailure.php index 4b319da..4b319da 100644 --- a/StorageAccessFailure.php +++ b/src/StorageAccessFailure.php diff --git a/TagNode.php b/src/TagNode.php index 2527b55..2527b55 100644 --- a/TagNode.php +++ b/src/TagNode.php diff --git a/TextNode.php b/src/TextNode.php index d48c2bb..d48c2bb 100644 --- a/TextNode.php +++ b/src/TextNode.php diff --git a/Transcompiler.php b/src/Transcompiler.php index 8f3213b..4988624 100644 --- a/Transcompiler.php +++ b/src/Transcompiler.php @@ -1,5 +1,8 @@ <?php +// File: Transcompiler.php + +// Namespace: kch42\ste namespace kch42\ste; /* diff --git a/VarNotInScope.php b/src/VarNotInScope.php index 179d07a..179d07a 100644 --- a/VarNotInScope.php +++ b/src/VarNotInScope.php diff --git a/VariableNode.php b/src/VariableNode.php index b312e81..b312e81 100644 --- a/VariableNode.php +++ b/src/VariableNode.php @@ -4,37 +4,37 @@ namespace ste; /* This file is for backwards compatibility only. Use an autoloader and the \kch42\ste namespace in new applications instead! */ -require_once(__DIR__ . "/Misc.php"); +require_once(__DIR__ . "/src/Misc.php"); -require_once(__DIR__ . "/ASTNode.php"); -require_once(__DIR__ . "/TagNode.php"); -require_once(__DIR__ . "/TextNode.php"); -require_once(__DIR__ . "/VariableNode.php"); +require_once(__DIR__ . "/src/ASTNode.php"); +require_once(__DIR__ . "/src/TagNode.php"); +require_once(__DIR__ . "/src/TextNode.php"); +require_once(__DIR__ . "/src/VariableNode.php"); -require_once(__DIR__ . "/ParseCompileError.php"); -require_once(__DIR__ . "/RuntimeError.php"); -require_once(__DIR__ . "/FatalRuntimeError.php"); +require_once(__DIR__ . "/src/ParseCompileError.php"); +require_once(__DIR__ . "/src/RuntimeError.php"); +require_once(__DIR__ . "/src/FatalRuntimeError.php"); -require_once(__DIR__ . "/BreakException.php"); -require_once(__DIR__ . "/ContinueException.php"); +require_once(__DIR__ . "/src/BreakException.php"); +require_once(__DIR__ . "/src/ContinueException.php"); -require_once(__DIR__ . "/StorageAccessFailure.php"); -require_once(__DIR__ . "/CantLoadTemplate.php"); -require_once(__DIR__ . "/CantSaveTemplate.php"); +require_once(__DIR__ . "/src/StorageAccessFailure.php"); +require_once(__DIR__ . "/src/CantLoadTemplate.php"); +require_once(__DIR__ . "/src/CantSaveTemplate.php"); -require_once(__DIR__ . "/StorageAccess.php"); -require_once(__DIR__ . "/FilesystemStorageAccess.php"); +require_once(__DIR__ . "/src/StorageAccess.php"); +require_once(__DIR__ . "/src/FilesystemStorageAccess.php"); -require_once(__DIR__ . "/Calc.php"); +require_once(__DIR__ . "/src/Calc.php"); -require_once(__DIR__ . "/Parser.php"); -require_once(__DIR__ . "/Transcompiler.php"); +require_once(__DIR__ . "/src/Parser.php"); +require_once(__DIR__ . "/src/Transcompiler.php"); -require_once(__DIR__ . "/VarNotInScope.php"); -require_once(__DIR__ . "/Scope.php"); +require_once(__DIR__ . "/src/VarNotInScope.php"); +require_once(__DIR__ . "/src/Scope.php"); -require_once(__DIR__ . "/STEStandardLibrary.php"); -require_once(__DIR__ . "/STECore.php"); +require_once(__DIR__ . "/src/STEStandardLibrary.php"); +require_once(__DIR__ . "/src/STECore.php"); /* Providing "proxy classes", so old applications can continue using the ste namespace */ diff --git a/steloader.php b/steloader.php index 166f52d..a54bb5f 100644 --- a/steloader.php +++ b/steloader.php @@ -9,7 +9,7 @@ function autoload_ste($cl) { $path = explode("\\", $cl); if(($path[0] == "kch42") && ($path[1] == "ste")) { - require_once(__DIR__ . "/" . $path[2] . ".php"); + require_once(__DIR__ . "/src/" . $path[2] . ".php"); } } |