Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Conditional color formatting ---- HTML

by talexb (Chancellor)
on Aug 22, 2018 at 14:54 UTC ( [id://1220843]=note: print w/replies, xml ) Need Help??


in reply to Conditional color formatting ---- HTML

It looks like you are implementing the beginnings of a templating system. As you've probably guessed, this isn't the first time someone's thought about doing this.

I've have very good success with Template::Toolkit as a templating system. The advantage of doing this is that it separates the presentation of the output from the business logic within the script.

In your case, you would pass the information in to the template, and then use logic in the template (example below) to modify the display of the data.

[% IF line.match('MATCH') %] <div style="background-color: orange"> [% ELSE %] <div> [% END %] [% line %] </div>
See this page for information on how I wrote this example.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1220843]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found