Gossamer Forum
Home : Gossamer Threads Inc. : Discussion :

Re: [webmaster33] [Suggestion] New GT template system

Quote Reply
Re: [webmaster33] [Suggestion] New GT template system In reply to
There is a good example in the GT::Template::Tutorial, which shows the great possibilities of the new, improved LSQL v3.0 template system.

Quote:
Another useful example is in including a common header or footer to all pages. If, for example, you have a header.htm that you wish to be included, but it needs a variable title, you could combine the include with a set, such as:

<%set Title = 'Login'%>
<%include header.htm%>

and then in your header.htm:

<html>
<head>
<title><%Title%></title>
</head>

This would allow you to have different titles, but still include the same header template on each page.

GT::Template also supports including a file based on the value of a variable by specifying the variable name (starting with a $) for the filename:

<%include $var%>

This allows for more powerful include abilities. For example, if you wanted to have a single outer template which includes another, variable template you could use an outer template (for the purposes of this example, assume this template is named 'outer.html') something like:

<html>
<head><title><%title%></title></head>
<body>
<div style="border: 5px solid black">
<%include $inner_template%>
</div>
</body>
</html>

Then, inside other templates, you would do:

abc.html:
=========

<%set inner_template = 'abc_content.html'%>
<%set title = 'ABC'%>
<%include layout.html%>

xyz.html:
=========

<%set inner_template = 'xyz_content.html'%>
<%set title = 'XYZ'%>
<%include layout.html%>

Now both abc.html and xyz.html would show up with the same page layout defined in layout.html, with a content section coming from their respective *_content.html templates.


It provides almost all features I listed earlier.
Directories - possible with <%include dir/file.html%>, so grouping is greatly possible
Inheritance - already possible since a long time
Variable files - possible to create variable files, where the tags are defined
using <%set tag='sometime'%> then this is included using <%include file.var%>,
then the <%include file.html%> is used, to display a file with changed variables
Skeleton-like template structure - possible using the technology mentioned in above GT::Template::Tutorial, using variable files.


3 important things are still missing from the GT template system:
  • Site level - missing
  • <%include $foo if%> - missing to include based on existance checking of currently used $foo variable
  • Multi-line set command - missing?

There would be nice, if GT would provide a template set, which is based on a skeleton-like template set, and provide several color themes of it (using inheritance) to show the possibilities of the GT template system.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Subject Author Views Date
Thread [Suggestion] New GT template system webmaster33 5149 Mar 23, 2005, 1:51 AM
Post Re: [webmaster33] [Suggestion] New GT template system
webmaster33 4942 Mar 23, 2005, 2:56 AM
Thread Re: [webmaster33] [Suggestion] New GT template system
webmaster33 4919 Mar 23, 2005, 7:50 AM
Post Re: [webmaster33] [Suggestion] New GT template system
webmaster33 4782 Apr 22, 2005, 4:41 PM
Post Re: [webmaster33] [Suggestion] New GT template system
webmaster33 4729 Apr 30, 2005, 3:08 PM