mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
Extend default handler
This commit is contained in:
@@ -56,6 +56,10 @@ class DefaultPluginHandlerTest extends PHPUnit_Smarty
|
||||
{
|
||||
$this->assertEquals("echo 'scriptcompilerfunction '.'foo bar';", $this->smarty->fetch('test_default_compiler_function_script.tpl'));
|
||||
}
|
||||
public function testDefaultCompilerObject()
|
||||
{
|
||||
$this->assertEquals('Public World', $this->smarty->fetch('test_default_compiler_object.tpl'));
|
||||
}
|
||||
|
||||
public function testDefaultBlockScript()
|
||||
{
|
||||
@@ -117,7 +121,9 @@ function my_plugin_handler($tag, $type, $template, &$callback, &$script, &$cacha
|
||||
case 'scriptcompilerfunction':
|
||||
$script = './scripts/script_compiler_function_tag.php';
|
||||
$callback = 'default_script_compiler_function_tag';
|
||||
|
||||
return true;
|
||||
case 'compilerobject':
|
||||
$callback = array(new CompilerDefaultPluginClass, 'compile');
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -165,3 +171,12 @@ function default_local_modifier($input)
|
||||
{
|
||||
return 'localmodifier ' . $input;
|
||||
}
|
||||
class CompilerDefaultPluginClass
|
||||
{
|
||||
static function statCompile ($params, $compiler) {
|
||||
return '<?php echo \'Static World\';?>';
|
||||
}
|
||||
public function compile ($params, $compiler) {
|
||||
return '<?php echo \'Public World\';?>';
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
{compilerobject value='foo bar'}
|
Reference in New Issue
Block a user