diff options
author | xue <> | 2005-12-25 20:25:42 +0000 |
---|---|---|
committer | xue <> | 2005-12-25 20:25:42 +0000 |
commit | cc44b9c507c6390c31a2f49f0a1f228a08c62b2e (patch) | |
tree | 0483c07258a787f8bb9cdd2c61b53e9e7795c1a3 | |
parent | 90821c0441285c3eb7a316202a660855ea9183eb (diff) |
Added template syntax explanation.
12 files changed, 234 insertions, 7 deletions
diff --git a/.gitattributes b/.gitattributes index d3f6df17..273f16ae 100644 --- a/.gitattributes +++ b/.gitattributes @@ -25,6 +25,9 @@ demos/quickstart/protected/pages/chap1/AboutPrado.page -text demos/quickstart/protected/pages/chap1/Installation.page -text demos/quickstart/protected/pages/chap1/Introduction.page -text demos/quickstart/protected/pages/chap1/config.xml -text +demos/quickstart/protected/pages/chap2/Templates1.page -text +demos/quickstart/protected/pages/chap2/Templates2.page -text +demos/quickstart/protected/pages/chap2/Templates3.page -text demos/quickstart/protected/pages/chap3/Hangman.page -text demos/quickstart/protected/pages/chap3/Hangman/Home.page -text demos/quickstart/protected/pages/chap3/Hangman/Home.php -text diff --git a/demos/quickstart/protected/pages/TopicList.tpl b/demos/quickstart/protected/pages/TopicList.tpl index 982a9168..0cfcb827 100644 --- a/demos/quickstart/protected/pages/TopicList.tpl +++ b/demos/quickstart/protected/pages/TopicList.tpl @@ -13,7 +13,9 @@ <a href="?page=chap2.KeyConcepts">Key Concepts</a><br/>
<a href="?page=chap2.Structure">Application Structure</a><br/>
<a href="?page=chap2.Configurations">Configurations</a><br/>
-<a href="?page=chap2.Templates">Templates</a><br/>
+<a href="?page=chap2.Templates1">Templates: Part I</a><br/>
+<a href="?page=chap2.Templates2">Templates: Part II</a><br/>
+<a href="?page=chap2.Templates3">Templates: Part III</a><br/>
</div>
<div class="topic">
diff --git a/demos/quickstart/protected/pages/chap1/AboutPrado.page b/demos/quickstart/protected/pages/chap1/AboutPrado.page index 0ffc25d3..03d9afe8 100644 --- a/demos/quickstart/protected/pages/chap1/AboutPrado.page +++ b/demos/quickstart/protected/pages/chap1/AboutPrado.page @@ -1,5 +1,5 @@ <com:TContent ID="body" >
-<h4>What is PRADO?</h4>
+<h1>What is PRADO?</h1>
<p>
PRADO stands for <b>P</b>HP <b>R</b>apid <b>A</b>pplication <b>D</b>evelopment
<b>O</b>bject-oriented.
diff --git a/demos/quickstart/protected/pages/chap1/Installation.page b/demos/quickstart/protected/pages/chap1/Installation.page index 77fd0b26..619d613f 100644 --- a/demos/quickstart/protected/pages/chap1/Installation.page +++ b/demos/quickstart/protected/pages/chap1/Installation.page @@ -1,5 +1,5 @@ <com:TContent ID="body" >
-<h4>Installing PRADO</h4>
+<h1>Installing PRADO</h1>
<p>
If you are viewing this page from your own Web server, you are already done with the installation. The instructions at the end of this page, however, may still be useful for you to troubleshoot issues happened during your development based on PRADO.
</p>
diff --git a/demos/quickstart/protected/pages/chap1/Introduction.page b/demos/quickstart/protected/pages/chap1/Introduction.page index b622b0d7..dc780c69 100644 --- a/demos/quickstart/protected/pages/chap1/Introduction.page +++ b/demos/quickstart/protected/pages/chap1/Introduction.page @@ -1,5 +1,5 @@ <com:TContent ID="body" >
-<h4>Welcome to the PRADO QuickStart Tutorial</h4>
+<h1>Welcome to the PRADO QuickStart Tutorial</h1>
<p>
This QuickStart tutorial is meant to get you quickly started to build your
own Web applications based on PRADO.
diff --git a/demos/quickstart/protected/pages/chap2/Templates1.page b/demos/quickstart/protected/pages/chap2/Templates1.page new file mode 100644 index 00000000..6984dd50 --- /dev/null +++ b/demos/quickstart/protected/pages/chap2/Templates1.page @@ -0,0 +1,69 @@ +<com:TContent ID="body" >
+<h1>Templates: Part I</h1>
+<p>
+Templates are used to specify the presentational layout of controls. A template can contain static text, components, or controls that contribute to the ultimate presentation of the associated control. By default, an instance of <code>TTemplateControl</code> or its subclass may automatically load a template from a file whose name is the same as the control class name. For page templates, the file name suffix must be <code>.page</code>; for other regular template controls, the suffix is <code>.tpl</code>.
+</p>
+<p>The template format is like HTML, with a few PRADO-specifc tags, including <a href="#ct">component tags</a>, <a href="#tct">template control tags</a>, <a href="#cot">comment tags</a>, <a href="?page=chap2.Templates2#dct">dynamic content tags</a>, and <a href="?page=chap2.Templates3#dpt">dynamic property tags</a>. .
+</p>
+
+<a name="ct" />
+<h2>Component Tags</h2>
+<p>
+A component tag specifies a component as part of the body content of the template control. If the component is a control, it usually will become a child or grand child of the template control, and its rendering result will be inserted at the place where it is appearing in the template.
+</p>
+<p>
+The format of a component tag is as follows,
+<pre class="source">
+<com:ComponentType PropertyName="PropertyValue" ... EventName="EventHandler" ...>
+body content
+</com:ComponentType>
+</pre>
+<code>ComponentType</code> can be either the class name or the dotted type name (e.g. <code>System.Web.UI.TControl</code>) of the component. <code>PropertyName</code> and <code>EventName</code> are both case-insensitive. <code>PropertyName</code> can be a property or subproperty name (e.g. <code>Font.Name</code>). Note, <code>PropertyValue</code> will be HTML-decoded when assigned to the corresponding property. Content enclosed between the opening and closing component tag are normally treated the body of the component.
+</p>
+<p>
+It is required that component tags nest properly with each other and an opening component tag be paired with a closing tag, similar to that in XML. The following shows a component tag specifying the <code>Text</code> property and <code>Click</code> event of a button control,
+<pre class="source">
+<com:TButton Text="Register" Click="registerUser" />
+</pre>
+</p>
+<p>
+To deal conveniently with properties taking take big trunk of initial data, the following property initialization tag is introduced,
+<pre class="source">
+<prop:PropertyName>
+PropertyValue
+</prop:PropertyName>
+</pre>
+It is equivalent to <code>...PropertyName="PropertyValue"...</code> in a component tag. Property initialization tags must be directly enclosed between the corresponding opening and closing component tag.
+</p>
+
+<a name="tct" />
+<h2>Template Control Tags</h2>
+A template control tag is used to configure the initial property values of the control owning the template. Its format is as follows,
+<pre class="source">
+<%@ PropertyName="PropertyValue" ... %>
+</pre>
+Like in component tags, <code>PropertyName</code> is case-insensitive and can be a property or subproperty name.
+</p>
+<p>
+Initial values specified via the template control tag are assigned to the corresponding properties when the template control is being constructed. Therefore, you may override these property values in a later stage, such as the <code>Init</code> stage of the control.
+</p>
+<p>
+Template control tag is optional in a template. Each template can contain at most one template control tag. You can place the template control tag anywhere in the template. It is recommended that you place it at the beginning of the template for better visibility.
+</p>
+
+<a name="cot" />
+<h2>Comment Tags</h2>
+<p>
+Comment tags are used to put comments in the template or the ultimate rendering result. There are two types of comment tags. One is like that in HTML and will be displayed to the end-users. The other only appear in a template and will be stripped out when the template is instantiated and displayed to the end-users. The format of these two comment tags is as follows,
+<pre class="source">
+<!--
+Comments VISIBLE to end-users
+-->
+
+<!
+Comments INVISIBLE to end-users
+!>
+</pre>
+</p>
+
+</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap2/Templates2.page b/demos/quickstart/protected/pages/chap2/Templates2.page new file mode 100644 index 00000000..b257a682 --- /dev/null +++ b/demos/quickstart/protected/pages/chap2/Templates2.page @@ -0,0 +1,78 @@ +<com:TContent ID="body" >
+<h1>Templates: Part II</h1>
+
+<a name="dct" />
+<h2>Dynamic Content Tags</h2>
+<p>
+Dynamic content tags are introduced as shortcuts to some commonly used <a href="?page=chap2.Templates1#ct">component tags</a>. These tags are mainly used to render contents resulted from evaluating some PHP expressions or statements. They include <a href="#et">expression tags</a>, <a href="#st">statement tags</a>, <a href="#dt">databind tags</a>, <a href="#pt">parameter tags</a> and <a href="#at">asset tags</a>.
+</p>
+
+<a name="et" />
+<h3>Expression Tags</h3>
+<p>
+An expression tag represents a PHP expression that is evaluated when the template control is being rendered. The expression evaluation result is inserted at the place where the tag resides in the template. Its format is as follows,
+<pre class="source">
+<%= PhpExpression %>
+</pre>
+Inernally, an expression tag is represented by a <code>TExpression</code> control. Therefore, in the expression <code>$this</code> refers to the <code>TExpression</code> control. For example, the following expression tag will display the current page title at the place,
+<pre class="source">
+<%= $this->Page->Title %>
+</pre>
+</p>
+
+<a name="st" />
+<h3>Statement Tags</h3>
+<p>
+Statement tags are similar to expression tags, except that statement tags contain PHP statements rather than expressions. The output of the PHP statements (using for example <code>echo</code> or <code>print</code> in PHP) are displayed at the place where the statement tag resides in the template. Inernally, a statement tag is represented by a <code>TStatements</code> control. Therefore, in the statements <code>$this</code> refers to the <code>TStatements</code> control. The format of statement tags is as follows,
+<pre class="source">
+<%%
+PHP Statements
+%>
+</pre>
+</p>
+<p>
+The following example displays the current time in Dutch at the place,
+<pre class="source">
+<%%
+setlocale(LC_ALL, 'nl_NL');
+echo strftime("%A %e %B %Y",time());
+%>
+</pre>
+</p>
+
+<a name="dt" />
+<h3>Databind Tags</h3>
+<p>
+Databind tags are similar to expression tags, except that the expressions are evaluated only when a <code>dataBind()</code> call is invoked on the controls representing the databind tags. Internally, a <code>TLiteral</code> control is used to represent a databind tag and <code>$this</code> in the expression would refer to the control. The format of databind tags is as follows,
+<pre class="source">
+<%# PhpExpression %>
+</pre>
+</p>
+
+<a name="pt" />
+<h3>Parameter Tags</h3>
+<p>
+Parameter tags are used to insert application parameters at the place where they appear in the template. The format of parameter tags is as follows,
+<pre class="source">
+<%$ ParameterName %>
+</pre>
+Note, application parameters are usually defined in application configurations or page directory configurations. The parameters are evaluated when the template is instantiated.
+</p>
+
+<a name="at" />
+<h3>Asset Tags</h3>
+<p>
+Asset tags are used to publish private files and display the corresponding the URLs. For example, if you have an image file that is not Web-accessible and you want to make it visible to end-users, you can use asset tags to publish this file and show the URL to end-users so that they can fetch the published image.
+</p>
+<p>
+The format of asset tags is as follows,
+<pre class="source">
+<%~ LocalFileName %>
+</pre>
+where <code>LocalFileName</code> refers to a file path that is relative to the directory containing the current template file. The file path can be a single file or a directory. If the latter, the content in the whole directory will be made accessible by end-users.
+</p>
+<p>
+BE VERY CAUTIOUS when you are using asset tags as it may expose to end-users files that you probably do not want them to see.
+</p>
+
+</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap2/Templates3.page b/demos/quickstart/protected/pages/chap2/Templates3.page new file mode 100644 index 00000000..328687fb --- /dev/null +++ b/demos/quickstart/protected/pages/chap2/Templates3.page @@ -0,0 +1,73 @@ +<com:TContent ID="body" >
+<h1>Templates: Part III</h1>
+
+<a name="dpt" />
+<h2>Dynamic Property Tags</h2>
+<p>
+Dynamic property tags are very similar to dynamic content tags, except that they are applied to component properties. The purpose of dynamic property tags is to allow more versatile component property configuration. Note, you are not required to use dynamic property tags because what can be done using dynamic property tags can also be done in PHP code. However, using dynamic property tags bring you much more convenience at accomplishing the same tasks. The basic usage of dynamic property tags is as follows,
+<pre class="source">
+<com:ComponentType PropertyName=DynamicPropertyTag ...>
+body content
+</com:ComponentType>
+</pre>
+where you may enclose <code>DynamicPropertyTag</code> within single or double quotes for better readability.
+</p>
+<p>
+We now introduce the available types of dynamic property tags that may be used in the above. Like dynamic content tags, we have <a href="#et">expression tags</a>, <a href="#dt">databind tags</a>, <a href="#pt">parameter tags</a> and <a href="#at">asset tags</a>. (Note, there is no statement tag here.)
+</p>
+
+<a name="et" />
+<h3>Expression Tags</h3>
+<p>
+An expression tag represents a PHP expression that is evaluated when the template is being instantiated. The expression evaluation result is assigned to the corresponding component property. The format of expression tags is as follows,
+<pre class="source">
+<%= PhpExpression %>
+</pre>
+In the expression, <code>$this</code> refers to the component specified by the component tag. The following example specifies a <code>TLabel</code> control whose <code>Text</code> property is initialized as the current page title when the <code>TLabel</code> control is being constructed,
+<pre class="source">
+<com:TLabel Text=<%= $this->Page->Title %> />
+</pre>
+</p>
+<p>
+Note, unlike dynamic content tags, the expressions tags for component properties are evaluated when the components are being constructed, while for the dynamic content tags, the expressions are evaluated when the controls are being rendered.
+</p>
+
+<a name="dt" />
+<h3>Databind Tags</h3>
+<p>
+Databind tags are similar to expression tags, except that the expressions are evaluated only when a <code>dataBind()</code> call is invoked on the controls represented by the component tags. In the expression, <code>$this</code> refers to the control itself. Databind tags do not apply to all components. They can only be used for controls.
+</p>
+<p>
+The format of databind tags is as follows,
+<pre class="source">
+<%# PhpExpression %>
+</pre>
+</p>
+
+<a name="pt" />
+<h3>Parameter Tags</h3>
+<p>
+Parameter tags are used to assign application parameter values to the corresponding component properties. The format of parameter tags is as follows,
+<pre class="source">
+<%$ ParameterName %>
+</pre>
+Note, application parameters are usually defined in application configurations or page directory configurations. The parameters are evaluated when the template is instantiated.
+</p>
+
+<a name="at" />
+<h3>Asset Tags</h3>
+<p>
+Asset tags are used to publish private files and assign the corresponding the URLs to the component properties. For example, if you have an image file that is not Web-accessible and you want to make it visible to end-users, you can use asset tags to publish this file and show the URL to end-users so that they can fetch the published image.
+</p>
+<p>
+The format of asset tags is as follows,
+<pre class="source">
+<%~ LocalFileName %>
+</pre>
+where <code>LocalFileName</code> refers to a file path that is relative to the directory containing the current template file. The file path can be a single file or a directory. If the latter, the content in the whole directory will be made accessible by end-users.
+</p>
+<p>
+BE VERY CAUTIOUS when you are using asset tags as it may expose to end-users files that you probably do not want them to see.
+</p>
+
+</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/chap3/Hangman.page b/demos/quickstart/protected/pages/chap3/Hangman.page index a1db7a25..b623bad4 100644 --- a/demos/quickstart/protected/pages/chap3/Hangman.page +++ b/demos/quickstart/protected/pages/chap3/Hangman.page @@ -1,5 +1,5 @@ <com:TContent ID="body" >
-<h4>Sample: Hangman Game</h4>
+<h1>Sample: Hangman Game</h1>
<p>
Having seen the simple "Hello World" application, we now build a more complex application called "Hangman Game". In this game, the player is asked to guess a word, a letter at a time. If he guesses a letter right, the letter will be shown in the word. The player can continue to guess as long as the number of his misses is within a prespecified bound. The player wins the game if he finds out the word within the miss bound, or he loses.
</p>
diff --git a/demos/quickstart/protected/pages/chap3/HelloWorld.page b/demos/quickstart/protected/pages/chap3/HelloWorld.page index 1db35d8b..a39aed33 100644 --- a/demos/quickstart/protected/pages/chap3/HelloWorld.page +++ b/demos/quickstart/protected/pages/chap3/HelloWorld.page @@ -1,5 +1,5 @@ <com:TContent ID="body" >
-<h4>Sample: Hello World</h4>
+<h1>Sample: Hello World</h1>
<p>
"Hello World" is the simplest <i>interactive</i> PRADO application that you can build. It displays to end-users a page with a submit button whose caption is <i>Click Me</i>. When the user clicks on the button, the button changes the caption to <i>Hello World</i>.
</p>
diff --git a/demos/quickstart/protected/pages/chap4/Overview.page b/demos/quickstart/protected/pages/chap4/Overview.page index 60671652..7c3fbea6 100644 --- a/demos/quickstart/protected/pages/chap4/Overview.page +++ b/demos/quickstart/protected/pages/chap4/Overview.page @@ -1,5 +1,5 @@ <com:TContent ID="body" >
-<h4>Controls Overview</h4>
+<h1>Controls Overview</h1>
<p>
A control is an instance of class <code>TControl</code> or its subclass. A control is a component defined in addition with user interface. The base class <code>TControl</code> defines the parent-child relationship among controls which reflects the containment relationship among user interface elements.
</p>
diff --git a/demos/quickstart/protected/pages/chap4/Simple1.page b/demos/quickstart/protected/pages/chap4/Simple1.page index e69de29b..a608c8d2 100644 --- a/demos/quickstart/protected/pages/chap4/Simple1.page +++ b/demos/quickstart/protected/pages/chap4/Simple1.page @@ -0,0 +1,2 @@ +<com:TContent ID="body" >
+</com:TContent>
\ No newline at end of file |