Shaji, 

 I've
recently (6 months ago) created just such an application.  My
approach was to create a simple template engine that supports 3 kinds
of "tags".  The template engine will read a template
file looking for these tags.  When a tag is found, the text for
the tag is replaced by a some value (perhaps sourced from a
database).  The text around the tags is simply echoed out to a
file or stdout. 

 The
three types of tags are:
        1.  Simple text replacement.
        2.  A tag with an associated callback.
        3. A Command tag.

 As
stated before the simple tag is simply a text replace for the tag
with a new value.  Optionally, a callback can be implemented to
perform some action as a result of encountering the tag such as a
formatting the value or performing a calculation.  The command
tag is a little special.  It has a beginning and an ending. 
The text between is considered a "sub template" and a
callback is associated with the command.  This is how I
implement things like looping. 

 The
main idea of this approach is to build the template file in HTML in
the first place, embed tags in the HTML, and separate the process of
obtaining the data from the actual rendering of the template. 
The engine it self could also be called an "Event Based Parser"
if that helps. 

 One
other feature that I implemented in this template system was to make
the whitespace around the tags optionally significant.  Not
important for HTML reports but I can "visually" build plain
text reports using a text editor when needed. 

 The
solution weighs in at about 800 lines of Perl and is built with OOP
design.  So, to answer your question, you may want to consider a
templatesolution.  Whether you roll your own solution like
I did or use an existing template solution, I would consider this
approach both viable and effective.


HTH

 --
Ronald Weidner
Software developer for
hire.
http://www.techport80.com


________________________________
 From: *Shaji Kalidasan* <shajiin...@yahoo.com>
To: Perl Beginners <beginners@perl.org> 
Sent: Saturday, July 6, 2013 10:43 AM
Subject: Is there a way to generate HTML reports?
 


Greetings,

As I understand, Perl has excellent report-generation capabilities. By using 
formats, we can actually visualize how our output will look because the 
definition of a format in Perl is very similar to what you see on the output. 
Is there any way we to convert these formats into HTML reports?

My goal is to create good looking HTML reports. Please suggest/advice.


Any help is highly appreciated.
 
best,
Shaji 
-------------------------------------------------------------------------------
Your talent is God's gift to you. What you do with it is your gift back to God.
-------------------------------------------------------------------------------

Reply via email to