A Pattern without objects.


Parts of your pages are repeating. You would like to encapsulate these parts to make maintainance easier.


If you are using templates, its easy. Write a function that fills a subtemplate and returns it filled in. The return value is interpolated into the main template.


You have a login consisting of username input and password input that you want to appear on several pages. If the user is already logged in, you want to display a logout button instead. The session object knows, if the user is logged in.
# We fill the login subtemplate
$display{'LOGIN'}	= login($session);
# $tmpl is the main template
interpolate(\$tmpl, %display);


Your page layout becomes more modular. If you apply the technique properly, you get something pretty close to a GUI component.