mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
fix code frame of inline (merged) subtemplate
This commit is contained in:
@@ -110,7 +110,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
// must use individual cache file
|
// must use individual cache file
|
||||||
$_attr['caching'] = 1;
|
$_attr['caching'] = 1;
|
||||||
}
|
}
|
||||||
if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) {
|
if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) {
|
||||||
$compiler->trigger_template_error(' variable template file names not allow within {block} tags');
|
$compiler->trigger_template_error(' variable template file names not allow within {block} tags');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,13 +124,12 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
// must use individual cache file
|
// must use individual cache file
|
||||||
$_attr['caching'] = 1;
|
$_attr['caching'] = 1;
|
||||||
}
|
}
|
||||||
if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) {
|
if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) {
|
||||||
$compiler->trigger_template_error(' variable compile_id not allow within {block} tags');
|
$compiler->trigger_template_error(' variable compile_id not allow within {block} tags');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the {include} tag provides individual parameter for caching or compile_id
|
* if the {include} tag provides individual parameter for caching or compile_id
|
||||||
* the subtemplate must not be included into the common cache file and is treated like
|
* the subtemplate must not be included into the common cache file and is treated like
|
||||||
@@ -197,9 +196,9 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
// make sure whole chain gets compiled
|
// make sure whole chain gets compiled
|
||||||
$tpl->mustCompile = true;
|
$tpl->mustCompile = true;
|
||||||
if (!($tpl->source->uncompiled) && $tpl->source->exists) {
|
if (!($tpl->source->uncompiled) && $tpl->source->exists) {
|
||||||
|
$tpl->compiler->suppressTemplatePropertyHeader = true;
|
||||||
// get compiled code
|
// get compiled code
|
||||||
$compiled_code = $tpl->compiler->compileTemplate($tpl, null, $compiler->parent_compiler);
|
$compiled_code = Smarty_Internal_Extension_CodeFrame::createFunctionFrame($tpl, $tpl->compiler->compileTemplate($tpl, null, $compiler->parent_compiler));
|
||||||
$compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['nocache_hash'] = $tpl->properties['nocache_hash'];
|
$compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['nocache_hash'] = $tpl->properties['nocache_hash'];
|
||||||
unset($tpl->compiler);
|
unset($tpl->compiler);
|
||||||
|
|
||||||
|
@@ -73,4 +73,19 @@ class Smarty_Internal_Extension_CodeFrame
|
|||||||
$output .= "<?php }\n}\n?>";
|
$output .= "<?php }\n}\n?>";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function createFunctionFrame(Smarty_Internal_Template $_template, $content = '')
|
||||||
|
{
|
||||||
|
if (!isset($_template->properties['unifunc'])) {
|
||||||
|
$_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
|
||||||
|
}
|
||||||
|
$output = "<?php\n";
|
||||||
|
$output .= "/*%%SmartyHeaderCode:{$_template->properties['nocache_hash']}%%*/\n";
|
||||||
|
$output .= "function {$_template->properties['unifunc']} (\$_smarty_tpl) {\n";
|
||||||
|
$output .= "?>\n" . $content;
|
||||||
|
$output .= "<?php\n";
|
||||||
|
$output .= "/*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/\n";
|
||||||
|
$output .= "}\n?>";
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user