summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TTemplateManager.php
diff options
context:
space:
mode:
authorxue <>2006-05-05 12:14:48 +0000
committerxue <>2006-05-05 12:14:48 +0000
commit94583ceb3e1d6bb2ab7a61c4907487a152fb4801 (patch)
tree5fcb9cd8f42c352147ef61a4dc422911ee587c95 /framework/Web/UI/TTemplateManager.php
parentdb7d5e7d65bba035a5adedc84d683f3195bf27ea (diff)
Merge from 3.0 branch till 1033.
Diffstat (limited to 'framework/Web/UI/TTemplateManager.php')
-rw-r--r--framework/Web/UI/TTemplateManager.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index 27bd0ac6..6e12726a 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -132,7 +132,9 @@ class TTemplateManager extends TModule
* - directive: directive specifies the property values for the template owner.
* It is in the format of &lt;% property name-value pairs %&gt;
* - expressions: They are in the formate of &lt;= PHP expression &gt; and &lt;% PHP statements &gt;
- * - comments: Special template comments enclosed within &lt;!-- comments --!&gt; will be stripped out.
+ * - comments: There are two kinds of comments, regular HTML comments and special template comments.
+ * The former is in the format of &lt;!-- comments --&gt;, which will be treated as text strings.
+ * The latter is in the format of &lt;%* comments %&gt;, which will be stripped out.
*
* Tags other than the above are not required to be well-formed.
*
@@ -150,12 +152,13 @@ class TTemplate extends TApplicationComponent implements ITemplate
{
/**
* '<!--.*?--!>' - template comments
+ * '<!--.*?-->' - HTML comments
* '<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>' - component tags
* '<\/?prop:([\w\.]+)\s*>' - property tags
* '<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>' - directives
* '<%[%#~\\$=\\[](.*?)%>' - expressions
*/
- const REGEX_RULES='/<!--.*?--!>|<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>/msS';
+ const REGEX_RULES='/<!--.*?--!>|<!--.*?-->|<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>/msS';
/**
* Different configurations of component property/event/attribute
@@ -664,11 +667,15 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
else if(strpos($str,'<!--')===0) // comments
{
- if($expectPropEnd)
- throw new TConfigurationException('template_comments_forbidden');
- if($matchStart>$textStart)
- $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
- $textStart=$matchEnd+1;
+ if(strrpos($str,'--!>')===strlen($str)-4) // template comments
+ {
+ if($expectPropEnd)
+ throw new TConfigurationException('template_comments_forbidden');
+ if($matchStart>$textStart)
+ $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
+ $textStart=$matchEnd+1;
+ }
+ // else, HTML comments and we do nothing
}
else
throw new TConfigurationException('template_matching_unexpected',$match);