mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
*** empty log message ***
This commit is contained in:
@@ -102,6 +102,7 @@ class Smarty
|
|||||||
var $_literal_blocks = array(); // keeps literal template blocks
|
var $_literal_blocks = array(); // keeps literal template blocks
|
||||||
var $_current_file = null; // the current template being compiled
|
var $_current_file = null; // the current template being compiled
|
||||||
var $_current_line_no = 1; // line number for error messages
|
var $_current_line_no = 1; // line number for error messages
|
||||||
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
@@ -483,10 +484,14 @@ class Smarty
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*======================================================================*\
|
||||||
|
Function: _process_cached_inserts
|
||||||
|
Purpose: Replace cached inserts with the actual results
|
||||||
|
\*======================================================================*/
|
||||||
function _process_cached_inserts($results)
|
function _process_cached_inserts($results)
|
||||||
{
|
{
|
||||||
preg_match_all('!\{\{\{insert_cache (.*)\}\}\}!Uis', $results, $match);
|
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||||
|
$results, $match);
|
||||||
list($cached_inserts, $insert_args) = $match;
|
list($cached_inserts, $insert_args) = $match;
|
||||||
|
|
||||||
for ($i = 0; $i < count($cached_inserts); $i++) {
|
for ($i = 0; $i < count($cached_inserts); $i++) {
|
||||||
@@ -622,7 +627,7 @@ class Smarty
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->caching)
|
if($this->caching)
|
||||||
return "{{{insert_cache $tag_args}}}";
|
return $this->_smarty_md5."{insert_cache $tag_args}".$this->_smarty_md5;
|
||||||
|
|
||||||
foreach ($attrs as $arg_name => $arg_value) {
|
foreach ($attrs as $arg_name => $arg_value) {
|
||||||
if ($arg_name == 'name') continue;
|
if ($arg_name == 'name') continue;
|
||||||
@@ -924,7 +929,7 @@ class Smarty
|
|||||||
case 0:
|
case 0:
|
||||||
/* If the token is a valid identifier, we set attribute name
|
/* If the token is a valid identifier, we set attribute name
|
||||||
and go to state 1. */
|
and go to state 1. */
|
||||||
if (preg_match('!\w+!', $token)) {
|
if (preg_match('!^\w+$!', $token)) {
|
||||||
$attr_name = $token;
|
$attr_name = $token;
|
||||||
$state = 1;
|
$state = 1;
|
||||||
} else
|
} else
|
||||||
|
@@ -4,6 +4,10 @@ require("Smarty.class.php");
|
|||||||
|
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
|
|
||||||
|
$smarty->caching = false;
|
||||||
|
|
||||||
|
$smarty->assign(now, time());
|
||||||
|
|
||||||
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
|
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
|
||||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||||
@@ -15,4 +19,11 @@ $smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" =>
|
|||||||
|
|
||||||
$smarty->display("index.tpl");
|
$smarty->display("index.tpl");
|
||||||
|
|
||||||
|
function insert_foo($args)
|
||||||
|
{
|
||||||
|
extract($args);
|
||||||
|
|
||||||
|
return "test $arg1";
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -46,3 +46,8 @@ testing strip tags
|
|||||||
{/strip}
|
{/strip}
|
||||||
|
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
|
test: {$now|date_format:"%I:%M %p"}
|
||||||
|
|
||||||
|
{insert name = foo arg1=5}
|
||||||
|
|
||||||
|
11
index.php
11
index.php
@@ -4,6 +4,10 @@ require("Smarty.class.php");
|
|||||||
|
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
|
|
||||||
|
$smarty->caching = false;
|
||||||
|
|
||||||
|
$smarty->assign(now, time());
|
||||||
|
|
||||||
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
|
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
|
||||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||||
@@ -15,4 +19,11 @@ $smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" =>
|
|||||||
|
|
||||||
$smarty->display("index.tpl");
|
$smarty->display("index.tpl");
|
||||||
|
|
||||||
|
function insert_foo($args)
|
||||||
|
{
|
||||||
|
extract($args);
|
||||||
|
|
||||||
|
return "test $arg1";
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -102,6 +102,7 @@ class Smarty
|
|||||||
var $_literal_blocks = array(); // keeps literal template blocks
|
var $_literal_blocks = array(); // keeps literal template blocks
|
||||||
var $_current_file = null; // the current template being compiled
|
var $_current_file = null; // the current template being compiled
|
||||||
var $_current_line_no = 1; // line number for error messages
|
var $_current_line_no = 1; // line number for error messages
|
||||||
|
var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
@@ -483,10 +484,14 @@ class Smarty
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*======================================================================*\
|
||||||
|
Function: _process_cached_inserts
|
||||||
|
Purpose: Replace cached inserts with the actual results
|
||||||
|
\*======================================================================*/
|
||||||
function _process_cached_inserts($results)
|
function _process_cached_inserts($results)
|
||||||
{
|
{
|
||||||
preg_match_all('!\{\{\{insert_cache (.*)\}\}\}!Uis', $results, $match);
|
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||||
|
$results, $match);
|
||||||
list($cached_inserts, $insert_args) = $match;
|
list($cached_inserts, $insert_args) = $match;
|
||||||
|
|
||||||
for ($i = 0; $i < count($cached_inserts); $i++) {
|
for ($i = 0; $i < count($cached_inserts); $i++) {
|
||||||
@@ -622,7 +627,7 @@ class Smarty
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->caching)
|
if($this->caching)
|
||||||
return "{{{insert_cache $tag_args}}}";
|
return $this->_smarty_md5."{insert_cache $tag_args}".$this->_smarty_md5;
|
||||||
|
|
||||||
foreach ($attrs as $arg_name => $arg_value) {
|
foreach ($attrs as $arg_name => $arg_value) {
|
||||||
if ($arg_name == 'name') continue;
|
if ($arg_name == 'name') continue;
|
||||||
@@ -924,7 +929,7 @@ class Smarty
|
|||||||
case 0:
|
case 0:
|
||||||
/* If the token is a valid identifier, we set attribute name
|
/* If the token is a valid identifier, we set attribute name
|
||||||
and go to state 1. */
|
and go to state 1. */
|
||||||
if (preg_match('!\w+!', $token)) {
|
if (preg_match('!^\w+$!', $token)) {
|
||||||
$attr_name = $token;
|
$attr_name = $token;
|
||||||
$state = 1;
|
$state = 1;
|
||||||
} else
|
} else
|
||||||
|
@@ -46,3 +46,8 @@ testing strip tags
|
|||||||
{/strip}
|
{/strip}
|
||||||
|
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
|
test: {$now|date_format:"%I:%M %p"}
|
||||||
|
|
||||||
|
{insert name = foo arg1=5}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user