Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

CSS and perl

by bakunin (Scribe)
on Sep 30, 2003 at 09:47 UTC ( #295229=perlquestion: print w/replies, xml ) Need Help??
bakunin has asked for the wisdom of the Perl Monks concerning the following question:

Hello all!

I searched CPAN for CSS related modules. 3 came to my attention.
CSS package
CSS::Tiny package

I want simple writing and reading via CGI, no fancy stuff. CSS::Tiny is very suitable for this purpose.

But I'd like to hear your thoughts, experiences with CSS and perl. For example, I'm working on LAYOUTs. I want to write a class that manages complicated layout creation. I will define the layout as a matrix, and each element in the matrix will specify a "box" in the web page, and carry specific (CSS and more)information about that box.

Replies are listed 'Best First'.
Re: CSS and perl
by jeffa (Bishop) on Sep 30, 2003 at 13:17 UTC
    Use Perl to generate your skeleton? Nonesense. All i do is create a "skeleton" that describes the layout. I usually start by lifting a layout from Box Lessons. Then i either use HTML::Template or Template. Here is a quick skeleton that i used recently with Template-Toolkit:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ +/"> <html xmlns=""> <head> <link rel="stylesheet" href="/css/default.css" type="text/css" /> <title>[% title %]</title> </head> <body> <div id="top"> <h1>[% title %]</h1> </div> <div id="left"> [% PROCESS widget/menu.html %] </div> <div id="middle"> [% content -%] </div> <div id="right"> [% PROCESS widget/calendar.html %] </div> <div id="bottom"> [% PROCESS widget/footer.html %] </div> </body> </html>
    As you can see, the CSS file is completely seperate and not generated by Perl! Instead, Perl is used to load this template and substitute, etc. This is, IMHO, a much better solution as it allows me to hand my HTML to someone who designs and doesn't code.

    So, in conclusion, my experience has been that the more flexible and useful applications of Perl and CSS are to simply template the skeleton and let Perl worry about the data, not the presentation. Otherwise you might as well be using Tk.


    (the triplet paradiddle with high-hat)
      I kneel in reverence to the (very prestigious) saint whom honoured my humble node.

      Yes, it was one of the replies I was expecting.
      I'm fully aware of the full potential of templating with HTML::Template,TT, Embperl and like...

      Nonsense?? Maybe...
      Honestly, I hate mark up. Of course I use it as others do. But I'm trying to avoid being friends with it. Of course there are modules and plugins that minimize the mark up usage in templating tools.

      I just love extreme integration. (Even in math!! hehehe)I think I'm writing my own templating system in which there is no mark up but OO integration of CGI, and DBI, and CSS, and hey even dynamic SWF generation via (ming)Perl.
      My purpose is to integrate PRESENTATION+ DATA. And if exists, may GOD spare us from Tk...

      I might have not expressed my intention properly, besides it wasn't the point in the first place; the fact is, I'm not creating a skeleton with CSS layout. Maybe for I am a physicist, I'd like to think everything in matrices.
      As a skeleton analogy suggests, skeleton itself, holds the body together, upright... In this case, it is my matrix that holds everything, and layout is just one of the things it holds...
      The skeleton is the MATRIX! Each matrix element describes a unique DIV, and inside the matrix element we have many many other references related to presentation and data, living happily together...
      When I finish what I am trying to, I'll show it!!
        I see more of where you are going with this now. While i still see it as potential overkill, i can still where it might be useful. I'd like to see what you come up with. I am still a bit suspicious about using this for clients who really want more flash than substance, but for those of us who care more about the data, this could be useful.


        (the triplet paradiddle with high-hat)
      Jeffa, Are you aware of any problem doing exactly as above with mod_perl. I can't seem to get the CSS to load. avron
        was a configuration issue, now resolved !
Re: CSS and perl
by dws (Chancellor) on Sep 30, 2003 at 14:53 UTC
    I'm working on LAYOUTs. I want to write a class that manages complicated layout creation. I will define the layout as a matrix, and each element in the matrix will specify a "box" in the web page, and carry specific (CSS and more)information about that box.

    Work the problem backwards. Get your layout working with static HTML, then either

    1. Templatize the HTML using HTML::Template or Template::Toolkit, or
    2. Break the HTML up into pieces and get Perl to print them somehow.

    Note that this is completely independent of CSS.

Re: CSS and perl
by Anonymous Monk on Sep 30, 2003 at 10:42 UTC
    My experience has been that perl is good for generating compact yet valid css.

    What is slowing you down in developing your app?

      It's part of a network of perl modules as I described in my bio. For some reason, I'd like use structs in my layout
      module(s). I think that's why I'm taking the implementation slow. I have to think what I should include in each matrix element.
      it'll be finished in a few days I hope!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://295229]
Approved by broquaint
[Corion]: 1nickt: Finding autobox in production would give me pause, yes
[LanX]: efficient survey
[MidLifeXis]: And under MINGW64_NT-6.1 MYHOST 2.6.0(0.304/5/3) 2016-09-09 09:46 x86_64 Msys there seem to be issues with escapes in external build tool calls.
[Corion]: I mean, it's a technical feat it achieves, but... why? ;)
[MidLifeXis]: And it also has the 0.14 version of the tarball in its manifest.
[LanX]: avoiding unreadable brackets
[MidLifeXis]: Although the previous one could be a b0rken PATH, I would need to dig for that.
[thezip]: I've got to go to meetings now. If anyone has further comments regarding Spreadsheet::XLSX deployment to Strawberry Perl 5.24.1, please /msg me -- thanks!
LanX has to go ... plans to crash with a car into a group of pythonistas while screaming "LARRY IS THE GREATEST"
LanX ... darn ... where is my car?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2017-03-23 17:28 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (291 votes). Check out past polls.