mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-03 05:41:37 +01:00 
			
		
		
		
	- changed name of {template} tag to {function}
This commit is contained in:
		@@ -1,19 +1,19 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
* Smarty Internal Plugin Compile Template
 | 
			
		||||
* Smarty Internal Plugin Compile Function
 | 
			
		||||
* 
 | 
			
		||||
* Compiles the {template} tag
 | 
			
		||||
* Compiles the {function} tag
 | 
			
		||||
* 
 | 
			
		||||
* @package Smarty
 | 
			
		||||
* @subpackage Compiler
 | 
			
		||||
* @author Uwe Tews 
 | 
			
		||||
*/
 | 
			
		||||
/**
 | 
			
		||||
* Smarty Internal Plugin Compile Template Class
 | 
			
		||||
* Smarty Internal Plugin Compile Function Class
 | 
			
		||||
*/
 | 
			
		||||
class Smarty_Internal_Compile_Template extends Smarty_Internal_CompileBase {
 | 
			
		||||
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
 | 
			
		||||
    /**
 | 
			
		||||
    * Compiles code for the {template} tag
 | 
			
		||||
    * Compiles code for the {function} tag
 | 
			
		||||
    * 
 | 
			
		||||
    * @param array $args array with attributes from parser
 | 
			
		||||
    * @param object $compiler compiler object
 | 
			
		||||
@@ -27,10 +27,10 @@ class Smarty_Internal_Compile_Template extends Smarty_Internal_CompileBase {
 | 
			
		||||
        // check and get attributes
 | 
			
		||||
        $_attr = $this->_get_attributes($args);
 | 
			
		||||
        $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
 | 
			
		||||
        $this->_open_tag('template', $save);
 | 
			
		||||
        $this->_open_tag('function', $save);
 | 
			
		||||
        $_name = trim($_attr['name'], "'");
 | 
			
		||||
        foreach ($_attr as $_key => $_data) {
 | 
			
		||||
            $compiler->template->properties['template'][$_name]['parameter'][$_key] = $_data;
 | 
			
		||||
            $compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
 | 
			
		||||
        } 
 | 
			
		||||
        $compiler->template->extract_code = true;
 | 
			
		||||
        $compiler->template->extracted_compiled_code = '';
 | 
			
		||||
@@ -1,19 +1,19 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
* Smarty Internal Plugin Compile Template Close
 | 
			
		||||
* Smarty Internal Plugin Compile Function Close
 | 
			
		||||
* 
 | 
			
		||||
* Compiles the {/template} tag
 | 
			
		||||
* Compiles the {/function} tag
 | 
			
		||||
* 
 | 
			
		||||
* @package Smarty
 | 
			
		||||
* @subpackage Compiler
 | 
			
		||||
* @author Uwe Tews 
 | 
			
		||||
*/
 | 
			
		||||
/**
 | 
			
		||||
* Smarty Internal Plugin Compile TemplateClose Class
 | 
			
		||||
* Smarty Internal Plugin Compile FunctionClose Class
 | 
			
		||||
*/
 | 
			
		||||
class Smarty_Internal_Compile_TemplateClose extends Smarty_Internal_CompileBase {
 | 
			
		||||
class Smarty_Internal_Compile_FunctionClose extends Smarty_Internal_CompileBase {
 | 
			
		||||
    /**
 | 
			
		||||
    * Compiles code for the {/template} tag
 | 
			
		||||
    * Compiles code for the {/function} tag
 | 
			
		||||
    * 
 | 
			
		||||
    * @param array $args array with attributes from parser
 | 
			
		||||
    * @param object $compiler compiler object
 | 
			
		||||
@@ -28,13 +28,13 @@ class Smarty_Internal_Compile_TemplateClose extends Smarty_Internal_CompileBase
 | 
			
		||||
        // check and get attributes
 | 
			
		||||
        $this->optional_attributes = array('name');
 | 
			
		||||
        $_attr = $this->_get_attributes($args);
 | 
			
		||||
        $saved_data = $this->_close_tag(array('template')); 
 | 
			
		||||
        $saved_data = $this->_close_tag(array('function')); 
 | 
			
		||||
        // if name does match to opening tag
 | 
			
		||||
        if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) {
 | 
			
		||||
            $this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"');
 | 
			
		||||
        } 
 | 
			
		||||
        $_name = trim($saved_data[0]['name'], "'");
 | 
			
		||||
        $compiler->template->properties['template'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code);
 | 
			
		||||
        $compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code);
 | 
			
		||||
        $compiler->template->extracted_compiled_code = $saved_data[1];
 | 
			
		||||
        $compiler->template->extract_code = $saved_data[2];
 | 
			
		||||
        return true;
 | 
			
		||||
@@ -1,20 +1,20 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* Smarty Internal Plugin Compile TemplateCall
 | 
			
		||||
* Smarty Internal Plugin Compile Internalfunctioncall
 | 
			
		||||
* 
 | 
			
		||||
* Compiles the {templatecall} tag
 | 
			
		||||
* Compiles the {internalfunctioncall} tag
 | 
			
		||||
* 
 | 
			
		||||
* @package Smarty
 | 
			
		||||
* @subpackage Compiler
 | 
			
		||||
* @author Uwe Tews 
 | 
			
		||||
*/
 | 
			
		||||
/**
 | 
			
		||||
* Smarty Internal Plugin Compile TemplateCall Class
 | 
			
		||||
* Smarty Internal Plugin Compile Internalfunctioncall Class
 | 
			
		||||
*/
 | 
			
		||||
class Smarty_Internal_Compile_TemplateCall extends Smarty_Internal_CompileBase {
 | 
			
		||||
class Smarty_Internal_Compile_Internalfunctioncall extends Smarty_Internal_CompileBase {
 | 
			
		||||
    /**
 | 
			
		||||
    * Compiles code for the {templateall} tag
 | 
			
		||||
    * Compiles code for the {internalfunctioncall} tag
 | 
			
		||||
    * 
 | 
			
		||||
    * @param array $args array with attributes from parser
 | 
			
		||||
    * @param object $compiler compiler object
 | 
			
		||||
@@ -34,12 +34,12 @@ class Smarty_Internal_Compile_TemplateCall extends Smarty_Internal_CompileBase {
 | 
			
		||||
        }
 | 
			
		||||
        $_name = trim( $_attr['name'],"'");
 | 
			
		||||
        // create template object
 | 
			
		||||
        $_output = "<?php \$_template = new Smarty_Template ('string:', \$_smarty_tpl);"; 
 | 
			
		||||
        $_output = "<?php \$_template = new Smarty_Template ('string:', \$_smarty_tpl);\n"; 
 | 
			
		||||
        // assign default paramter
 | 
			
		||||
        if (isset($compiler->template->properties['template'][$_name]['parameter'])) {
 | 
			
		||||
            foreach ($compiler->template->properties['template'][$_name]['parameter'] as $_key => $_value) {
 | 
			
		||||
        if (isset($compiler->template->properties['function'][$_name]['parameter'])) {
 | 
			
		||||
            foreach ($compiler->template->properties['function'][$_name]['parameter'] as $_key => $_value) {
 | 
			
		||||
                if (!isset($_attr[$_key])) {
 | 
			
		||||
                    $_output .= "\$_template->assign('$_key',$_value);";
 | 
			
		||||
                    $_output .= "\$_template->assign('$_key',$_value);\n";
 | 
			
		||||
                } 
 | 
			
		||||
            } 
 | 
			
		||||
        } 
 | 
			
		||||
@@ -49,15 +49,15 @@ class Smarty_Internal_Compile_TemplateCall extends Smarty_Internal_CompileBase {
 | 
			
		||||
        if (!empty($_attr)) {
 | 
			
		||||
            // create variables
 | 
			
		||||
            foreach ($_attr as $_key => $_value) {
 | 
			
		||||
                $_output .= "\$_template->assign('$_key',$_value);";
 | 
			
		||||
                $_output .= "\$_template->assign('$_key',$_value);\n";
 | 
			
		||||
            } 
 | 
			
		||||
        }
 | 
			
		||||
        if (isset($compiler->template->properties['template'][$_name]['compiled'])) {
 | 
			
		||||
            $_compiled = str_replace(array('_%n',"'"), array('',"\'"), $compiler->template->properties['template'][$_name]['compiled']);
 | 
			
		||||
            $_output .= "\$_template->compiled_template = '$_compiled'; \$_template->mustCompile = false;";
 | 
			
		||||
        if (isset($compiler->template->properties['function'][$_name]['compiled'])) {
 | 
			
		||||
            $_compiled = str_replace(array('_%n',"'"), array("\n","\'"), $compiler->template->properties['function'][$_name]['compiled']);
 | 
			
		||||
            $_output .= "\$_template->compiled_template = '$_compiled';\n \$_template->mustCompile = false;\n";
 | 
			
		||||
        } else {
 | 
			
		||||
// for recursion
 | 
			
		||||
            $_output .= "\$_template->compiled_template = \$_smarty_tpl->compiled_template; \$_template->mustCompile = false;";
 | 
			
		||||
            $_output .= "\$_template->compiled_template = \$_smarty_tpl->compiled_template;\n \$_template->mustCompile = false;\n";
 | 
			
		||||
        }
 | 
			
		||||
        // was there an assign attribute
 | 
			
		||||
        if (isset($_assign)) {
 | 
			
		||||
@@ -112,10 +112,10 @@ class Smarty_Internal_TemplateCompilerBase extends Smarty_Internal_Base {
 | 
			
		||||
        $this->has_code = true;
 | 
			
		||||
        $this->has_output = false; 
 | 
			
		||||
        // compile the smarty tag (required compile classes to compile the tag are autoloaded)
 | 
			
		||||
        if (isset($this->template->properties['template'][$tag])) {
 | 
			
		||||
        if (isset($this->template->properties['function'][$tag])) {
 | 
			
		||||
            // template defined by {template} tag
 | 
			
		||||
            $args['name'] = $tag;
 | 
			
		||||
            $tag = 'templatecall';
 | 
			
		||||
            $tag = 'internalfunctioncall';
 | 
			
		||||
        } 
 | 
			
		||||
        if (!($_output = $this->$tag($args, $this)) === false) {
 | 
			
		||||
            if ($_output !== true) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user