|
Basic concepts $x by the content (on page 01 "Mother", on page 02 "World").$x on the picture) and the value that it assumes (related database).M(VR)C (R stands "renderer"), where data details such as date format ("11/10/2006" or "2006-10-11" presentation) or decimal point ("1,000,000" or "1000000" presentation) need to solved without breaking the separation strategy. A classical solution is to "pre-process" the data on template engine with renderer functions. Good CSS use can also solve a lot of these casesFormal characterization For a formal, but not rigorous, definition of web template, we can modeling the template system as a dataflow: Let: Basic Properties: Important conclusions from this definition: print (it is not a hook), are not. Kinds of web templates
Examples A complete list of implemented web templates and template engines is on Template systems article. Template format strategies A usual template is a single file (or a single record into a database) and it may to reference another resources for logical dependences or layout dependences. This file is fomated with very specific markup, that reflects the template system strategies. Sub-template use strategies Template systems produce web documents as output, in a "output language" (eg. HTML). A template with no instruction (for process on template engine) is also the output document. The template language is an output language with embedded instructions in a scripting language. There are two main kinds of template languages, referring the output language: Hook compatibility strategies All template format deal with two languages: the script language, and the output language. One embedding another. NOTE: some template systems like Cocoon permits interchange into the same file (see how to embed xsp:content into xsp:logic). Template syntax need special care with the "border" between languages, to avoid mixing and to supply scaping forms. There are well defined tags, marks or characteres, named "hooks", that intend to separate the two languages. This hooks may be reconfigurable. Types of hook: Usual examples for script hooks (hidden blocks) and language styles: <% script %> ASP style script ?> PHP style ColdFusion style XSLT style C preprocessor (or CheetahTemplate) style SSI style Cocoon style (where script is a single expression) XQuery styleUsual examples for re-used script blocks: ColdFusion "set and output" custo-tag style XSLT "use and def" styleUsual examples for expressions and language styles: <%=x %> ASP style=$x ?> PHP style="$x $y" ?> PHP interpolation style ColdFusion interpolation style Cocoon style Smarty, XQuery and XSLT styles XSLT style XSLT styleUsual examples for custom-tags or parametrized macros: <%=foo(v1,v2) %> ASP style=foo(v1,v2) ?> PHP style XQuery style Coldfusion styleTemplate languages The syntax to express variables, blocks, substitution rules, or logic, in a web template, is formalized by a template language. The standards of a template language can be fixed into a engine dependent or independent context: Languages hierarchy Template languages can be grouped in a hierarchy The main divisory line, from the good separation principles perspective, is about Programable/Iterable (Context-sensitive / Context-free). From (power to produce) algorithms perspective, the upper line between Complex and others. Simple substitution templates Only variable syntax rules exist, not logic neither iteration. They are very restricted, only substitution and simple macro expansion can be doed. The "double quotes preprocessor" into languages like PERL or PHP, on print "Hello $x" statements, are good examples. Features: 1. Scalar variable expansion. 1.1. Externally defined. 1.1.1. Pre-defined: see SSI or PHP ($ENV) HTTP environment variables. 1.1.2. User-defined (from user-defined input resource) See fig. example where "Hello " turns "Hello Mother" or "Hello World". 1.2 Internally defined. Note: if it have scalar externally defined variables, it will be replaced by values. 1.2.1. Hidden specification. In a Embedded template language it is not content, is hidden and may be never used. C preprocessor example:
1.2.2. Block re-use specification. In a Embedded template language the block specification is also part of the template. Examples:
2. Parametrized block expansion or "Sub-template expansion" (concatenation macros). 2.1. Pre-defined. 2.2. User-defined. Hidde block example:
Block re-use example, where also scalar externally defined variables was replaced by values.
Iterable templates Theoretical formal definition: Regular and context-free templates. Same as simple templates, but with iteration capabilities. It can repeat a substitution in the scope of a single block, providing a "do-repeat" logic. Features: Programable templates They support "side-effect free" logic. Examples: XSLT and StringTemplate. Complex templates They support unrestricted logic, for specify any sequetial algorithm. Have features like to permit parametrization, "if-then-else", "while-repeat", and many other statements for substitution control. Smarty template language and the "server-side extension module languages" like PHP, JSP, ASP, ColdFusion are examples. Theoretical formal definition: Unrestricted templates. Template reuse and repositories We can "recycle" web templates. Web templates are sometimes free, and easily made by an individual domestically. However, specialized web templates are sometimes sold online. While there are numerous commercial sites that offer web templates, there are also free and "open-source" sources. Template files Usually a "simple template" will include most of the source files necessary for further customizing the template. There are two cases (motivations) to need more than 1 file per template: History Adapted and resumed from Template system history. Is difficult to be precise about "web template beginnings" or chronology, because it started only after the "widespread development of web pages", and there are a lot of parallel developments. Web templates, as "web designers necessity", started with the HTML and web browsers popularization. After this, different kinds of templates was dominated the web template scenery: The high diversity of "template languages" (as a kind of "sub-language" of the CMS or the server-side programming languages), pointed to the need for a "template standard language". The matureness of XSLT and standardization of XQuery, promises, for near future, a kind of convergence. See also Wiki templates are, also, a good examples: the wiki engine is the template engine, and a (the web template) is used into a set of articles (the content). | |||||||||||
|
| ||||||||||||
![]() |
|
| |