mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
fixed <?php tag at beginning of files, updated docs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
|
||||
require_once "PEAR.php";
|
||||
|
||||
|
7
FAQ
7
FAQ
@@ -88,3 +88,10 @@ Q: I get this error when passing variables to {include}:
|
||||
/path/to/Smarty/templates_c/index.tpl.php on line 8
|
||||
A: get_defined_vars() was added to PHP 4.0.4. If you plan on passing
|
||||
variables to included templates, you will need PHP 4.0.4 or later.
|
||||
|
||||
Q: I get PHP errors in my {if} tag logic.
|
||||
A: All conditional qualifiers must be separated by spaces. This syntax will not
|
||||
work: {if $name=="Wilma"} You must instead do this: {if $name == "Wilma"}.
|
||||
The reason for this is syntax ambiguity. Both "==" and "eq" are equivalent
|
||||
in the template parser, so something like {if $nameeq"Wilma"} wouldn't be
|
||||
parsable by the tokenizer.
|
||||
|
@@ -505,8 +505,9 @@ class Smarty
|
||||
'{literal}', $template_contents);
|
||||
|
||||
/* Gather all template tags. */
|
||||
preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_contents, $match);
|
||||
preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}(\n)?!s", $template_contents, $match);
|
||||
$template_tags = $match[1];
|
||||
$template_newlines = $match[2];
|
||||
/* Split content by template tags to obtain non-template content. */
|
||||
$text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_contents);
|
||||
|
||||
@@ -515,12 +516,12 @@ class Smarty
|
||||
/* loop through text blocks */
|
||||
for($curr_tb = 0; $curr_tb <= count($text_blocks); $curr_tb++) {
|
||||
/* match anything within <? ?> */
|
||||
if(preg_match_all('!(<\?[^?]*?\?>|<script\s+language\s*=\s*[\"\']?php[\"\']?\s*>)!i',$text_blocks[$curr_tb],$sp_match)) {
|
||||
if(preg_match_all('!(<\?[^?]*?\?>|<script\s+language\s*=\s*[\"\']?php[\"\']?\s*>)(\n)?!i',$text_blocks[$curr_tb],$sp_match)) {
|
||||
/* found at least one match, loop through each one */
|
||||
foreach($sp_match[0] as $curr_sp) {
|
||||
for($curr_sp = 0; $curr_sp <= count($sp_match[0]); $curr_sp++) {
|
||||
if(!$this->allow_php) {
|
||||
/* we don't allow php, so echo everything */
|
||||
$text_blocks[$curr_tb] = str_replace($curr_sp,'<?php echo \''.str_replace("'","\'",$curr_sp).'\'; ?>',$text_blocks[$curr_tb]);
|
||||
$text_blocks[$curr_tb] = str_replace($sp_match[0][$curr_sp],'<?php echo \''.str_replace("'","\'",$sp_match[0][$curr_sp]).'\'; ?>',$text_blocks[$curr_tb]);
|
||||
}
|
||||
elseif(!preg_match("!^(<\?(php | )|<script\s*language\s*=\s*[\"\']?php[\"\']?\s*>)!i",$curr_sp))
|
||||
/* we allow php, so echo only non-php tags */
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
|
||||
require("Smarty.class.php");
|
||||
|
||||
|
@@ -1242,7 +1242,8 @@ Intro = """This is a value that spans more
|
||||
"gt", "lt", "lte", "le", "gte" "ge","is even","is odd", "is not
|
||||
even","is not odd","not","mod","div by","even by","odd
|
||||
by","==","!=",">", "<","<=",">=" are all valid conditional
|
||||
qualifiers.
|
||||
qualifiers, and must be separated from surrounding elements by
|
||||
spaces.
|
||||
</para>
|
||||
<example>
|
||||
<title>if statements</title>
|
||||
@@ -1266,6 +1267,12 @@ Intro = """This is a value that spans more
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* the following syntax will NOT work, conditional qualifiers
|
||||
must be separated from surrounding elements by spaces *}
|
||||
{if $name=="Fred" || $name=="Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
|
||||
{* parenthesis are allowed *}
|
||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
|
||||
require_once "PEAR.php";
|
||||
|
||||
|
@@ -505,8 +505,9 @@ class Smarty
|
||||
'{literal}', $template_contents);
|
||||
|
||||
/* Gather all template tags. */
|
||||
preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_contents, $match);
|
||||
preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}(\n)?!s", $template_contents, $match);
|
||||
$template_tags = $match[1];
|
||||
$template_newlines = $match[2];
|
||||
/* Split content by template tags to obtain non-template content. */
|
||||
$text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_contents);
|
||||
|
||||
@@ -515,12 +516,12 @@ class Smarty
|
||||
/* loop through text blocks */
|
||||
for($curr_tb = 0; $curr_tb <= count($text_blocks); $curr_tb++) {
|
||||
/* match anything within <? ?> */
|
||||
if(preg_match_all('!(<\?[^?]*?\?>|<script\s+language\s*=\s*[\"\']?php[\"\']?\s*>)!i',$text_blocks[$curr_tb],$sp_match)) {
|
||||
if(preg_match_all('!(<\?[^?]*?\?>|<script\s+language\s*=\s*[\"\']?php[\"\']?\s*>)(\n)?!i',$text_blocks[$curr_tb],$sp_match)) {
|
||||
/* found at least one match, loop through each one */
|
||||
foreach($sp_match[0] as $curr_sp) {
|
||||
for($curr_sp = 0; $curr_sp <= count($sp_match[0]); $curr_sp++) {
|
||||
if(!$this->allow_php) {
|
||||
/* we don't allow php, so echo everything */
|
||||
$text_blocks[$curr_tb] = str_replace($curr_sp,'<?php echo \''.str_replace("'","\'",$curr_sp).'\'; ?>',$text_blocks[$curr_tb]);
|
||||
$text_blocks[$curr_tb] = str_replace($sp_match[0][$curr_sp],'<?php echo \''.str_replace("'","\'",$sp_match[0][$curr_sp]).'\'; ?>',$text_blocks[$curr_tb]);
|
||||
}
|
||||
elseif(!preg_match("!^(<\?(php | )|<script\s*language\s*=\s*[\"\']?php[\"\']?\s*>)!i",$curr_sp))
|
||||
/* we allow php, so echo only non-php tags */
|
||||
|
Reference in New Issue
Block a user