- correct line number on unknown tag error message

- changed {include} compiled code
This commit is contained in:
Uwe.Tews
2009-11-26 22:49:56 +00:00
parent f3f01b928a
commit 25270df6bd
4 changed files with 14 additions and 17 deletions

View File

@@ -1,5 +1,7 @@
11/26/2009
- bugfix on nested doublequoted strings
- correct line number on unknown tag error message
- changed {include} compiled code
11/25/2009
- allow the following writing for boolean: true, TRUE, True, false, FALSE, False

View File

@@ -100,11 +100,10 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
$_parent_scope = SMARTY_GLOBAL_SCOPE;
}
}
$_caching= 'null';
// default for included templates
if ($this->compiler->template->caching && !$this->compiler->nocache) {
$_caching = 9999;
} else {
$_caching = SMARTY_CACHING_OFF;
}
/*
* if the {include} tag provides individual parameter for caching
@@ -115,7 +114,9 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
$_cache_lifetime = $_attr['cache_lifetime'];
$this->compiler->tag_nocache = true;
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
}
} else {
$_cache_lifetime = 'null';
}
if (isset($_attr['nocache'])) {
if ($_attr['nocache'] == 'true') {
$this->compiler->tag_nocache = true;
@@ -131,7 +132,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
}
}
// create template object
$_output = "<?php \$_template = new Smarty_Template ($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id);";
$_output = "<?php \$_template = new Smarty_Template ($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id, $_caching, $_cache_lifetime);";
// delete {include} standard attributes
unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope']);
// remaining attributes must be assigned as smarty variable
@@ -145,12 +146,6 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
$this->compiler->trigger_template_error('variable passing not allowed in parent/global scope');
}
}
// add caching parameter if required
if (isset($_cache_lifetime)) {
$_output .= "\$_template->cache_lifetime = $_cache_lifetime;";
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
}
$_output .= "\$_template->caching = $_caching;";
// was there an assign attribute
if (isset($_assign)) {
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate()); ?>";

View File

@@ -76,15 +76,15 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
* @param mixed $_cache_id cache id or null
* @param mixed $_compile_id compile id or null
*/
public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null)
public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null)
{
$this->smarty = $smarty;
// Smarty parameter
$this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id;
$this->compile_id = $_compile_id === null ? $this->smarty->compile_id : $_compile_id;
$this->force_compile = $this->smarty->force_compile;
$this->caching = $this->smarty->caching;
$this->cache_lifetime = $this->smarty->cache_lifetime;
$this->caching = $_caching === null ? $this->smarty->caching : $_caching;
$this->cache_lifetime = $_cache_lifetime === null ?$this->smarty->cache_lifetime : $_cache_lifetime;
$this->force_cache = $this->smarty->force_cache;
$this->cacher_class = $this->smarty->cacher_class;
$this->caching_type = $this->smarty->default_caching_type;
@@ -573,10 +573,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
} else {
$_return = call_user_func_array($this->smarty->default_template_handler_func,
array($this->resource_type, $this->resource_name, &$this->template_source, &$this->template_timestamp, $this));
if ($_return == true) {
return $file;
} elseif (is_string($_return)) {
if (is_string($_return)) {
return $_return;
} elseif ($_return === true) {
return $file;
}
}
}

View File

@@ -235,7 +235,7 @@ class Smarty_Internal_TemplateCompilerBase {
{
// get template source line which has error
if (!isset($line)) {
$line = $this->lex->line;
$line = $this->lex->line;
}
$match = preg_split("/\n/", $this->lex->data);
$error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . $match[$line-1] . '" ';