Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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
[haukex]: I figure someone who wants to contribute will know how to install the missing modules ;-) Not the nicest way to go but I don't think many people are using my modules yet
[ambrus]: Corion: some of these stupid syntax highlighters assume that too. just look at the table in http://perldoc. functions/pack. html for example.
[haukex]: ..."yet" ;-) I haven't had to deal with Dist::Zilla yet but I've heard about how it's a big setup
[ambrus]: I really don't like automagic stuff. I'm happy when computers do exactly what I tell them, even if that means they sometimes do the wrong thing.
[ambrus]: And I don't much like syntax highlighters. If you need a syntax highlighter to understand your code, then your code is written unclear.
[ambrus]: And if you need a syntax highlighter to color parenthesis green and numbers black and letters blue, then you're using the wrong font.
[ambrus]: I have to tolerate syntax highlighters when other people use them, but I don't use them myself. And sorry for the rant.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2017-02-27 12:43 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.