Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

CSS and perl

by bakunin (Scribe)
on Sep 30, 2003 at 09:47 UTC ( [id://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::SAC
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:/ +/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <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.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (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.

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-03-19 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found