Posts Tagged ‘templates

I need a better templating language, one where an included (called) template can change its containing (caller) template. For example, consider this container template:

<html>
<head>
<title>{define-spot name="title"}</title>
<script language="Javascript">
{define-spot name="js"}
</script>
</head>
<body>
{include file="inside.tpl"}
</body>
</html>

This container creates a spot where a title can be placed and where some javascript can be placed. It then includes another template file which will put content in those spots. This included template, inside.tpl, would look like the following:


{fill-spot id="title"}Jacob's Super Page{/fill-spot}
{fill-spot id="js"}alert('hello'};{/fill-spot}
<h1>Hello</h1>
<p>This is a sample template file</p>

The template language would also need to be flexible enough such that if the included template didn’t fill the spots, then things continue to work without without crashing, as if the spots had been filled with nothing.

The problem is that many template language translate their template into some sort of source code, and usually that source code turns out to be in a procedual language. This means that templates are parsed from top to bottom, so by the time the inside template is included, the template parser has already parsed the spots above it, and can’t go back and fill those spots (because that would require parsing the container template twice).

A posible solution may be available in some template language which would allow you to parse the inner template first by placing it at the top of the container template, capturing its output, and displaying it later. This would result in a less-elegant container template that might look like the following:


{capture to="inside-contents"}
{include file="inside.tpl"}
{/capture}
<html>
<head>
<title>{define-spot name="title"}</title>
<script language="Javascript">
{define-spot name="js"}
</script>
</head>
<body>
{show id="inside-contents}
</body>
</html>

Now using a new template

Posted in Technicalon Oct 12, 2006

You may have noticed that I’ve started using a new template on this site. It mostly works, but I’m working on tuning it up and making it better. Eventually, I will start using this theme on a couple of my other blogs.

Please let me know what you think and what I can do to make it better.

Exodus web page theme

Posted in Technicalon Oct 6, 2006

Exodus Theme The last couple of days I’ve been working on a new web design. This theme is called Exodus, because my previous and first theme was called Genesis.

I think that I’ll probably use this theme on my blog here. I’ve designed it from the ground up, and I hope to AJAX-ify it when I turn it into a WordPress theme.

Please let me know what you think.

Building a template

Posted in Technicalon Mar 10, 2006

Template ThumbshotI’ve been working on a web page template to use in an upcoming project, although it might as well be used on thing like this blog or other project. Anyway, it is art, and it is a work in progress. It is fully XHTML complient (I think) and it is starting to come together. I am trying to figure out though how exactly to make it better. Feel free to take a look at it and let me know what you think.


Categories