-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Function-Calls, loop break, loop continue
You can by now define own Functions
- Loading branch information
matthes
committed
Oct 11, 2017
1 parent
17cc851
commit ce4778f
Showing
11 changed files
with
242 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: matthes | ||
* Date: 11.10.17 | ||
* Time: 07:42 | ||
*/ | ||
|
||
namespace Leuffen\TextTemplate; | ||
|
||
|
||
class __BreakLoopException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: matthes | ||
* Date: 11.10.17 | ||
* Time: 07:43 | ||
*/ | ||
|
||
namespace Leuffen\TextTemplate; | ||
|
||
|
||
class __ContinueLoopException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: matthes | ||
* Date: 10.10.17 | ||
* Time: 15:20 | ||
*/ | ||
|
||
|
||
namespace Leuffen\TextTemplate; | ||
|
||
TextTemplate::$__DEFAULT_FILTER["_DEFAULT_"] = function ($input) { return htmlspecialchars($input); }; | ||
|
||
// Raw is only a pseudo-filter. If it is not in the chain of filters, __DEFAULT__ will be appended to the filter | ||
TextTemplate::$__DEFAULT_FILTER["html"] = function ($input) { return htmlspecialchars($input); }; | ||
TextTemplate::$__DEFAULT_FILTER["raw"] = function ($input) { return $input; }; | ||
TextTemplate::$__DEFAULT_FILTER["singleLine"] = function ($input) { return str_replace("\n", " ", $input); }; | ||
TextTemplate::$__DEFAULT_FILTER["inivalue"] = function ($input) { return addslashes(str_replace("\n", " ", $input)); }; | ||
|
||
TextTemplate::$__DEFAULT_FILTER["fixedLength"] = function ($input, $length, $padChar=" ") { | ||
return str_pad(substr($input, 0, $length), $length, $padChar); | ||
}; | ||
|
||
TextTemplate::$__DEFAULT_FILTER["inflect"] = function ($input, $type="tag") { | ||
switch ($type) { | ||
case "tag": | ||
return preg_replace("/[^a-z0-9]/im", "_", trim(strtolower($input))); | ||
|
||
|
||
default: | ||
return "##ERR:inflect:$type - unknown type: '$type'##"; | ||
} | ||
}; | ||
|
||
TextTemplate::$__DEFAULT_FILTER["sanitize"] = function ($input, $type) { | ||
switch ($type) { | ||
case "hostname": | ||
return preg_replace("/[^a-z0-9\.\-]/im", "", trim(strtolower($input))); | ||
|
||
default: | ||
return "##ERR:sanitize:$type - unknown type: '$type'##"; | ||
} | ||
}; |
Oops, something went wrong.