From 506e38f76ba73dc78264da442e6e0f64fc42c117 Mon Sep 17 00:00:00 2001 From: mohrt Date: Tue, 8 Aug 2000 21:10:12 +0000 Subject: [PATCH] update include path bug --- README | 11 ++++++++--- Smarty.class.php | 8 +++++++- libs/Smarty.class.php | 8 +++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README b/README index 435b31ba..3a4e22f6 100644 --- a/README +++ b/README @@ -166,7 +166,7 @@ templates/index.php {include header.tpl} {* This is a template comment *} hello, my name is {$Name}.
-{if $Name == "Joe"} +{if $Name eq "Joe"} I am Joe.
{else} I am not Joe.
@@ -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: diff --git a/Smarty.class.php b/Smarty.class.php index c7cec662..cb912959 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -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[] = ""; $search[] = "/^".$ld."\s*include\s*\"?([^\s\}]+)\"?".$rd."$/i"; // replace include tags - $replace[] = ""; + $replace[] = ""; $search[] = "/^".$ld."\s*section\s+name\s*=\s*\"?([\w\d]+)\"?\s+\\\$([^\}\s]+)\s*".$rd."$/i"; // replace section tags $replace[] = ""; $search[] = "/^".$ld."\s*\/section\s*".$rd."$/i"; // replace /section tags diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index c7cec662..cb912959 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -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[] = ""; $search[] = "/^".$ld."\s*include\s*\"?([^\s\}]+)\"?".$rd."$/i"; // replace include tags - $replace[] = ""; + $replace[] = ""; $search[] = "/^".$ld."\s*section\s+name\s*=\s*\"?([\w\d]+)\"?\s+\\\$([^\}\s]+)\s*".$rd."$/i"; // replace section tags $replace[] = ""; $search[] = "/^".$ld."\s*\/section\s*".$rd."$/i"; // replace /section tags