From cc44b9c507c6390c31a2f49f0a1f228a08c62b2e Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 25 Dec 2005 20:25:42 +0000 Subject: Added template syntax explanation. --- demos/quickstart/protected/pages/TopicList.tpl | 4 +- .../protected/pages/chap1/AboutPrado.page | 2 +- .../protected/pages/chap1/Installation.page | 2 +- .../protected/pages/chap1/Introduction.page | 2 +- .../protected/pages/chap2/Templates1.page | 69 +++++++++++++++++++ .../protected/pages/chap2/Templates2.page | 78 ++++++++++++++++++++++ .../protected/pages/chap2/Templates3.page | 73 ++++++++++++++++++++ .../quickstart/protected/pages/chap3/Hangman.page | 2 +- .../protected/pages/chap3/HelloWorld.page | 2 +- .../quickstart/protected/pages/chap4/Overview.page | 2 +- .../quickstart/protected/pages/chap4/Simple1.page | 2 + 11 files changed, 231 insertions(+), 7 deletions(-) create mode 100644 demos/quickstart/protected/pages/chap2/Templates1.page create mode 100644 demos/quickstart/protected/pages/chap2/Templates2.page create mode 100644 demos/quickstart/protected/pages/chap2/Templates3.page (limited to 'demos/quickstart/protected/pages') 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 @@ Key Concepts
Application Structure
Configurations
-Templates
+Templates: Part I
+Templates: Part II
+Templates: Part III
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 @@ -

What is PRADO?

+

What is PRADO?

PRADO stands for PHP Rapid Application Development Object-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 @@ -

Installing PRADO

+

Installing PRADO

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.

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 @@ -

Welcome to the PRADO QuickStart Tutorial

+

Welcome to the PRADO QuickStart Tutorial

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 @@ + +

Templates: Part I

+

+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 TTemplateControl 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 .page; for other regular template controls, the suffix is .tpl. +

+

The template format is like HTML, with a few PRADO-specifc tags, including component tags, template control tags, comment tags, dynamic content tags, and dynamic property tags. . +

+ + +

Component Tags

+

+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. +

+

+The format of a component tag is as follows, +

+<com:ComponentType PropertyName="PropertyValue" ... EventName="EventHandler" ...>
+body content
+</com:ComponentType>
+
+ComponentType can be either the class name or the dotted type name (e.g. System.Web.UI.TControl) of the component. PropertyName and EventName are both case-insensitive. PropertyName can be a property or subproperty name (e.g. Font.Name). Note, PropertyValue 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. +

+

+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 Text property and Click event of a button control, +

+<com:TButton Text="Register" Click="registerUser" />
+
+

+

+To deal conveniently with properties taking take big trunk of initial data, the following property initialization tag is introduced, +

+<prop:PropertyName>
+PropertyValue
+</prop:PropertyName>
+
+It is equivalent to ...PropertyName="PropertyValue"... in a component tag. Property initialization tags must be directly enclosed between the corresponding opening and closing component tag. +

+ +
+

Template Control Tags

+A template control tag is used to configure the initial property values of the control owning the template. Its format is as follows, +
+<%@ PropertyName="PropertyValue" ... %>
+
+Like in component tags, PropertyName is case-insensitive and can be a property or subproperty name. +

+

+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 Init stage of the control. +

+

+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. +

+ +
+

Comment Tags

+

+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, +

+<!--
+Comments VISIBLE to end-users
+-->
+
+<!
+Comments INVISIBLE to end-users
+!>
+
+

+ +
\ 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 @@ + +

Templates: Part II

+ +
+

Dynamic Content Tags

+

+Dynamic content tags are introduced as shortcuts to some commonly used component tags. These tags are mainly used to render contents resulted from evaluating some PHP expressions or statements. They include expression tags, statement tags, databind tags, parameter tags and asset tags. +

+ + +

Expression Tags

+

+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, +

+<%= PhpExpression %>
+
+Inernally, an expression tag is represented by a TExpression control. Therefore, in the expression $this refers to the TExpression control. For example, the following expression tag will display the current page title at the place, +
+<%= $this->Page->Title %>
+
+

+ +
+

Statement Tags

+

+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 echo or print in PHP) are displayed at the place where the statement tag resides in the template. Inernally, a statement tag is represented by a TStatements control. Therefore, in the statements $this refers to the TStatements control. The format of statement tags is as follows, +

+<%%
+PHP Statements
+%>
+
+

+

+The following example displays the current time in Dutch at the place, +

+<%%
+setlocale(LC_ALL, 'nl_NL');
+echo strftime("%A %e %B %Y",time());
+%>
+
+

+ +
+

Databind Tags

+

+Databind tags are similar to expression tags, except that the expressions are evaluated only when a dataBind() call is invoked on the controls representing the databind tags. Internally, a TLiteral control is used to represent a databind tag and $this in the expression would refer to the control. The format of databind tags is as follows, +

+<%# PhpExpression %>
+
+

+ +
+

Parameter Tags

+

+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, +

+<%$ ParameterName %>
+
+Note, application parameters are usually defined in application configurations or page directory configurations. The parameters are evaluated when the template is instantiated. +

+ +
+

Asset Tags

+

+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. +

+

+The format of asset tags is as follows, +

+<%~ LocalFileName %>
+
+where LocalFileName 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. +

+

+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. +

+ +
\ 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 @@ + +

Templates: Part III

+ +
+

Dynamic Property Tags

+

+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, +

+<com:ComponentType PropertyName=DynamicPropertyTag ...>
+body content
+</com:ComponentType>
+
+where you may enclose DynamicPropertyTag within single or double quotes for better readability. +

+

+We now introduce the available types of dynamic property tags that may be used in the above. Like dynamic content tags, we have expression tags, databind tags, parameter tags and asset tags. (Note, there is no statement tag here.) +

+ + +

Expression Tags

+

+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, +

+<%= PhpExpression %>
+
+In the expression, $this refers to the component specified by the component tag. The following example specifies a TLabel control whose Text property is initialized as the current page title when the TLabel control is being constructed, +
+<com:TLabel Text=<%= $this->Page->Title %> />
+
+

+

+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. +

+ +
+

Databind Tags

+

+Databind tags are similar to expression tags, except that the expressions are evaluated only when a dataBind() call is invoked on the controls represented by the component tags. In the expression, $this refers to the control itself. Databind tags do not apply to all components. They can only be used for controls. +

+

+The format of databind tags is as follows, +

+<%# PhpExpression %>
+
+

+ +
+

Parameter Tags

+

+Parameter tags are used to assign application parameter values to the corresponding component properties. The format of parameter tags is as follows, +

+<%$ ParameterName %>
+
+Note, application parameters are usually defined in application configurations or page directory configurations. The parameters are evaluated when the template is instantiated. +

+ +
+

Asset Tags

+

+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. +

+

+The format of asset tags is as follows, +

+<%~ LocalFileName %>
+
+where LocalFileName 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. +

+

+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. +

+ + \ 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 @@ -

Sample: Hangman Game

+

Sample: Hangman Game

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.

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 @@ -

Sample: Hello World

+

Sample: Hello World

"Hello World" is the simplest interactive PRADO application that you can build. It displays to end-users a page with a submit button whose caption is Click Me. When the user clicks on the button, the button changes the caption to Hello World.

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 @@ -

Controls Overview

+

Controls Overview

A control is an instance of class TControl or its subclass. A control is a component defined in addition with user interface. The base class TControl defines the parent-child relationship among controls which reflects the containment relationship among user interface elements.

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 @@ + + \ No newline at end of file -- cgit v1.2.3