Helma logo
helma.org » Home > docs > tutorial > Shaping The Output

Shaping The Output

Because the Person HopObjects are now attached to Root, we just need a simple interface to access them and make them display in the browser.

Here's a simple XHTML layout we can use:

apps/addressbook/Global/html.skin:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <title><% response.title %></title>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="white">

<% response.body %>

</body>
</html>
Instead of defining a generic title, I am using a placeholder <% response.title %>, just as the whole text body is substituted by <% response.body %>. Both placeholders will be replaced by "real" content, later.

Helma calls such placeholder structures "macros", the files fitted with such macros are called "skins", resp. "skin files". Skin files are behaving like templates, except that you absolutely cannot evaluate any scripting code in those. And that's again what macros are for. Macros are replaced by either the result of a function call or, like in this case, by the value of an object's property.

This is one of Helma's big virtues: the separation of data and presentation. Because it is a good idea to avoid putting layout elements into your code just as it is a good idea to avoid including scripting code in your layout. Helma's macro and skin concepts help you to prevent these big no-nos and if you follow this path your web applications will become more flexible and easier to deploy, even more beautiful.

To see how the two macros will work here, save this skin as html.skin in the directory addressbook/Global.


Up: Tutorial
Previous: Attaching HopObjects Next: Improvements

... comment


Page last modified on 2005-10-17 18:20 by czv