Skip to main content

HTML Templates

HTML::Template is a new solution to an old problem - Perl CGI development. In order to explain what makes HTML::Template new I'll briefly describe the history of Perl CGI development.

In the beginning, people wrote CGIs by scattering print statements throughout Perl scripts. The HTML that ended up on the user's screen was literally embedded in the Perl script. These scripts were very difficult to maintain. Even a small change, like switching fonts, required a programmer to edit the script. It was almost impossible for a non-programmer to edit the HTML without endangering the script itself! Thus, programmers were required for even the smallest design change. Given the relative shortage of programmers versus HTML designers, this is clearly not desired situation.

Many solutions to this problem have appeared, and many share a common trait - they invert the situation by embedding programming inside HTML. Examples of this approach are HTML::Mason, Embperl, ASP and PHP. Used well these tools can allow programmers and non-programmers to work on the same script/template. However, the Perl programming and the HTML are still in the same file, and opportunities for mishap are constantly present. Maintainence is easier in this situation, but still problematic.

HTML::Template approaches the problem differently. Using HTML::Template, the Perl code and the HTML text are kept totally separate. The HTML is put in a file called a template, and the Perl code is written in separate script files and modules. The HTML is enhanced with a few new tags providing variable substitution, looping and branching. On the Perl side, the programmer can set values for the variables, fill in loops and control branching.

Used well, HTML::Template allows Perl programmers and HTML designers to work totally independently. The HTML designers only need to learn a few new tags. All the programming takes place in Perl scripts and modules using HTML::Template's simple API.

I wrote HTML::Template because I don't enjoy editing HTML, I prefer programming! Call it laziness, but I think that the people who are good at something should be the people doing it. HTML designers are good at editing and maintaining HTML. Anything that stands needlessly in the way of their doing their job should be removed. By keeping the HTML design totally separate from the code, HTML::Template tries to do just that.
[Source: http://html-template.sourceforge.net/article.html]

Comments

Popular posts from this blog

Should we allow our staff to use social networking sites? Some people say they are dangerous but I can't see how. Can you explain the dangers? > EXPERT RESPONSE There's nothing wrong with using Facebook, other than the potential impact on working time, but that's not a security matter! The issue is in how your staff configures Facebook, and what information they place on it. A few tips to pass on to your staff: Don't allow anyone that isn't part of your network of 'friends' to see your profile. Don't allow non-friends to see your friends. Why? I could easily impersonate one of your friends, fake a new profile, and send you an invite. You accept, thinking a genuine friend has created a new profile, then I'm in your network of friends and can see your profile. Think about what information is in your profile. What would be useful in stealing your identity? Date of birth, address, email address, employer, interests. why does this type of information n...

How to Use Chisanbop (Korean Finger Math) for Basic Addition and Counting | eHow.com

How to Use Chisanbop (Korean Finger Math) for Basic Addition and Counting eHow.com Difficulty: Easy Instructions Step 1 In Chisanbop you'll be using your two hands and ten fingers to represent numbers from 0 to 99. Start out with your hands out in front of you with closed fists. This represents 0. Each finger (not thumb) on your right hand represents 1. To represent 3, just press down three right hand fingers. Your right thumb represents 5. To represent 7, press down your right thumb and 2 right hand fingers. Think of your right hand as the ones or units place (column). Step 2 Your left hand represents the tens place (column). Each finger on your left hand is worth 10. For example, to represent 30, press down three left hand fingers. To represent 38, do the same, but also use your right hand to represent 8 as described above. Your left thumb represents 50. To represent 86, press down your left thumb and three left hand fingers for the 80, and your right thumb and one righ...

some OOPS concepts and examples

The class is the description of the object and the object in an instance of the class. For example the class of humans would describe us as having the attributes such as arms, hands, legs and heads; and methods such as talk, think, eat, and sit. However each of us would be an instance of that class, an object. If I can jump it’s because humans can jump, if I can laugh, it’s because humans can laugh. That is, the class defines the methods and attributes for each object belonging to that class. POLYMORPHISM : Polymorphism is the ability for objects to respond differently to the same message, depending upon what type of object they are. For example, members from each of the following classes; Spouse, YoungerBrother, TotalStranger or LawEnforcementOfficer, are likely to behave differently when the hug method is called upon them. Polymorphism becomes very useful when we have a group of related objects upon which we want to perform an operation, but those objects may need to react in differe...