mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 09:54:27 +02:00
update include path bug
This commit is contained in:
11
README
11
README
@@ -166,7 +166,7 @@ templates/index.php
|
||||
{include header.tpl}
|
||||
{* This is a template comment *}
|
||||
hello, my name is {$Name}.<br>
|
||||
{if $Name == "Joe"}
|
||||
{if $Name eq "Joe"}
|
||||
I am Joe.<br>
|
||||
{else}
|
||||
I am not Joe.<br>
|
||||
@@ -193,14 +193,17 @@ IF/ELSE LOGIC:
|
||||
|
||||
Smarty supports if/else logic like so:
|
||||
|
||||
{if $Name == "John"}
|
||||
{if $Name eq "John"}
|
||||
I am John!
|
||||
{else}
|
||||
I am not John.
|
||||
{/if}
|
||||
|
||||
A few important things to know:
|
||||
* arguments to {if ..} are passed "as is" to the php parser.
|
||||
* arguments to {if ...} are passed "as is" to the php parser.
|
||||
* "eq", "ne","neq", "gt", "lt", "lte", "le", "gte" "ge",
|
||||
"==","!=",">","<","<=",">=" are all valid conditional
|
||||
qualifiers.
|
||||
|
||||
SECTIONS:
|
||||
|
||||
@@ -228,6 +231,8 @@ A few important things to know:
|
||||
like so: {$section_name.variable_name}
|
||||
* It is OK to mention variables of parent sections
|
||||
within nested child sections.
|
||||
* nothing in the section will display if the
|
||||
looping array is unset.
|
||||
|
||||
Sections can be nested, like so:
|
||||
|
||||
|
@@ -266,6 +266,12 @@ class Smarty
|
||||
if(!($template_contents = $this->_read_file($filepath)))
|
||||
return false;
|
||||
|
||||
if(preg_match("/^(.+)\/([^\/]+)$/",$compilepath,$match))
|
||||
{
|
||||
$ctpl_file_dir = $match[1];
|
||||
$ctpl_file_name = $match[2];
|
||||
}
|
||||
|
||||
if(!$this->allow_php)
|
||||
{
|
||||
// escape php tags in templates
|
||||
@@ -307,7 +313,7 @@ class Smarty
|
||||
$search[] = "/^".$ld."\s*\/if\s*".$rd."$/i"; // replace /if tags
|
||||
$replace[] = "<?php endif; ?>";
|
||||
$search[] = "/^".$ld."\s*include\s*\"?([^\s\}]+)\"?".$rd."$/i"; // replace include tags
|
||||
$replace[] = "<?php include(\"\\1\"); ?>";
|
||||
$replace[] = "<?php include(\"".$ctpl_file_dir."/\\1\"); ?>";
|
||||
$search[] = "/^".$ld."\s*section\s+name\s*=\s*\"?([\w\d]+)\"?\s+\\\$([^\}\s]+)\s*".$rd."$/i"; // replace section tags
|
||||
$replace[] = "<?php for(\$\\1_secvar=0; \$\\1_secvar<count(\$\\2); \$\\1_secvar++): ?>";
|
||||
$search[] = "/^".$ld."\s*\/section\s*".$rd."$/i"; // replace /section tags
|
||||
|
@@ -266,6 +266,12 @@ class Smarty
|
||||
if(!($template_contents = $this->_read_file($filepath)))
|
||||
return false;
|
||||
|
||||
if(preg_match("/^(.+)\/([^\/]+)$/",$compilepath,$match))
|
||||
{
|
||||
$ctpl_file_dir = $match[1];
|
||||
$ctpl_file_name = $match[2];
|
||||
}
|
||||
|
||||
if(!$this->allow_php)
|
||||
{
|
||||
// escape php tags in templates
|
||||
@@ -307,7 +313,7 @@ class Smarty
|
||||
$search[] = "/^".$ld."\s*\/if\s*".$rd."$/i"; // replace /if tags
|
||||
$replace[] = "<?php endif; ?>";
|
||||
$search[] = "/^".$ld."\s*include\s*\"?([^\s\}]+)\"?".$rd."$/i"; // replace include tags
|
||||
$replace[] = "<?php include(\"\\1\"); ?>";
|
||||
$replace[] = "<?php include(\"".$ctpl_file_dir."/\\1\"); ?>";
|
||||
$search[] = "/^".$ld."\s*section\s+name\s*=\s*\"?([\w\d]+)\"?\s+\\\$([^\}\s]+)\s*".$rd."$/i"; // replace section tags
|
||||
$replace[] = "<?php for(\$\\1_secvar=0; \$\\1_secvar<count(\$\\2); \$\\1_secvar++): ?>";
|
||||
$search[] = "/^".$ld."\s*\/section\s*".$rd."$/i"; // replace /section tags
|
||||
|
Reference in New Issue
Block a user