Project

General

Profile

TEMPLATE specification » History » Version 11

Werner Klinger, 01/05/2010 10:01 AM

1 1 Redmine Admin
h1. TEMPLATE specification
2 1 Redmine Admin
3 1 Redmine Admin
This is a new specification for a simple template format: raw HTML containing placeholders.
4 1 Redmine Admin
5 2 Redmine Admin
This template specification provides no looping capability. However, using the *part template*, it is possible to repeat a template section.
6 1 Redmine Admin
7 11 Werner Klinger
NOTE: this is *not* another template engine, it is solely a template specification, with a shared definition of template rules and keywords.
8 11 Werner Klinger
9 11 Werner Klinger
Useful links:
10 11 Werner Klinger
* http://www.broculos.net/tutorials/how_to_make_a_simple_html_template_engine_in_php/20080315/en
11 11 Werner Klinger
* http://articles.sitepoint.com/article/beyond-template-engine
12 11 Werner Klinger
* http://fabien.potencier.org/article/34/templating-engines-in-php
13 11 Werner Klinger
* http://www.livexp.net/technology/php/top-25-php-template-engines.html
14 11 Werner Klinger
* http://nicolas.desaleux.fr/index.php?post/2009/10/21/ND_Template-:-Un-moteur-de-template
15 11 Werner Klinger
16 1 Redmine Admin
h2. Full versus part template
17 1 Redmine Admin
18 1 Redmine Admin
h3. Full template
19 1 Redmine Admin
20 1 Redmine Admin
In case of a full template, the template file is a valid HTML file, including HTML, HEAD and BODY directives.
21 1 Redmine Admin
22 1 Redmine Admin
h3. Partial template
23 1 Redmine Admin
24 1 Redmine Admin
Partial template is made of HTML code, excluding any of the HTML, HEAD, BODY directives.
25 1 Redmine Admin
26 1 Redmine Admin
h2. Place holders and reserved keywords
27 1 Redmine Admin
28 1 Redmine Admin
h3. syntax
29 1 Redmine Admin
30 1 Redmine Admin
Placeholders and reserved keywords are delimited within template by '%' (percent) sign surrounding keyword:<pre>Here will the %placeholder% be replaced.</pre>
31 7 Werner Klinger
Werner: Placeholder choice to be discussed here (include your first name when adding comment here).
32 10 Werner Klinger
33 1 Redmine Admin
34 1 Redmine Admin
h3. Rules
35 1 Redmine Admin
36 5 Werner Klinger
Placeholders and reserved keywords are made of any characters from within [a-z], [A-Z], [0-9], '-' (dash) and '_' (underscore), and are case intolerant: _ABC_ and _abc_ designate the same placeholder, but _%ABC%_ may not be replaced properly if match is against _%abc%_. Indeed, performing a case insensitive search/replace is resources consuming.
37 1 Redmine Admin
38 1 Redmine Admin
h3. Reserved keywords
39 1 Redmine Admin
40 1 Redmine Admin
Some Placeholders are reserved for futur usage.
41 1 Redmine Admin
42 2 Redmine Admin
* *include*
43 1 Redmine Admin
* do
44 1 Redmine Admin
* loop
45 1 Redmine Admin
* while
46 1 Redmine Admin
* repeat
47 1 Redmine Admin
* break
48 1 Redmine Admin
* exit
49 3 Werner Klinger
* _any string starting with tpl_
50 3 Werner Klinger
51 3 Werner Klinger
h3. Pre-allocated placeholders
52 3 Werner Klinger
53 3 Werner Klinger
Some Placeholders have a predefined role. Sharing this roles amoung templates users is the main purpose of this specification.
54 3 Werner Klinger
55 3 Werner Klinger
* page_title
56 3 Werner Klinger
  page title for the TITLE directive
57 3 Werner Klinger
* title
58 3 Werner Klinger
  Page main title for the H1 directive
59 3 Werner Klinger
* subtitle
60 3 Werner Klinger
  Page subtitle, for wordpress like template (title/subtitle in header)
61 3 Werner Klinger
* content
62 3 Werner Klinger
  main page content, usually made of a huge amount of text.
63 3 Werner Klinger
* footer
64 3 Werner Klinger
  content for the footer area.
65 3 Werner Klinger
* breadcrumb
66 3 Werner Klinger
  Breadcrumb line
67 4 Werner Klinger
* menu
68 4 Werner Klinger
  main menu, usually vertical left
69 4 Werner Klinger
* nav
70 4 Werner Klinger
  navigation menu, usually horizontal in upper area
71 2 Redmine Admin
72 2 Redmine Admin
h2. Using a template
73 2 Redmine Admin
74 2 Redmine Admin
Using such a template in PHP is as easy as:
75 2 Redmine Admin
<pre>
76 2 Redmine Admin
77 2 Redmine Admin
</pre>