Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

CSS::Moonfall
port of Lua's Moonfall for dynamic CSS generation

CSS::Moonfall - port of Lua's Moonfall for dynamic CSS generation


NAME

CSS::Moonfall - port of Lua's Moonfall for dynamic CSS generation


VERSION

Version 0.03 released 15 Sep 07


SYNOPSIS


    package MySite::CSS;

    use CSS::Moonfall;

    our $page_width = 1000;

    our $colors = { background => '#000000', color => '#FFFFFF' };

    package main;

    print MySite::CSS->filter(<<'CSS');

    body { width: [page_width]; }

    #header { width: [$page_width-20]; [colors] }

    CSS


DESCRIPTION

Moonfall is an application for the dynamic generation of CSS. The problem it solves is making CSS more programmable. The most basic usage is to define variables within CSS (e.g., so similar elements can have their common color defined in one and only one place). CSS::Moonfall aims to be a faithful port from Lua to Perl.

See http://moonfall.org/ for more details.


DEVIATIONS FROM MOONFALL

Obviously CSS::Moonfall uses Perl (not Lua) as its programming language. :)

Moonfall is actually a standalone C program that filters CSS with its embedded Lua interpreter. CSS::Moonfall is a module that lets you easily builds the tools to do the same task.

Lua has only one data structure: the table. Perl has two: arrays and hashes. Lua's tables fulfill the purpose of both: it's an ordered table indexable by arbitrary strings. I've tried to make CSS::Moonfall let you use both arrays and hashes. You should really only use hashes (it feels nicer that way). Later versions may have extra semantics (such as guaranteed ordering) tied to arrays.


FUNCTIONS

The CSS::Moonfall module has two exports: fill and filter. fill is to be used by the Moonfall script itself, to aid in the creation of auto-sized fields. filter is used by modules calling your library to filter input.

fill HASHREF => HASHREF

Takes a hashref and uses the known values to fill in the unknown values. This is mostly useful for dynamically calculating the width of multiple elements.

You must pass in a nonzero total field which defines the total size. Pass in known values in the usual fashion (such as: center => 300). Unknown values should be explicitly set to undef (such as: left => undef).

Here's an example:


    fill { total => 1000, middle => 600, bottom => undef, top => undef }

        => { middle => 600, top => 200, bottom => 200 }

filter STRING => STRING

This takes the pseudo-CSS passed in and applies what it can to return real CSS. Text within brackets [...] is filtered through eval.

As a convenience, barewords (such as [foo]) will be replaced with the value of the global scalar with that name. If that scalar is a hash reference, then each (key, value) pair will be turned into CSS-style key: value; declarations. You may use underscores in key names instead of - to avoid having to quote the key. This means that if you want to call functions, you must include a pair of parentheses or something else to distinguish it from a bareword (much like in Perl itself for $hash{keys}.

Hashes (and arrays) are recursively expanded. If the input looks like this:


    our $default = {

        foo => {

            color => '#FF0000',

            baz => {

                background_color => '#000000',

            },

        },

    };

then you'll get output that looks like:


    color: #FF0000;

    background-color: #000000;

If any value looks like a plain integer, it will have px appended to it.


KNOWN BUGS

None!


SEE ALSO

The original Lua Moonfall: http://moonfall.org/


PORTER

Shawn M Moore, <sartak at gmail.com>


ORIGINAL AUTHOR

Kevin Swope, <kevin at moonfall.org>


BUGS

No known bugs.

Please report any bugs through RT: email bug-css-moonfall at rt.cpan.org, or browse to http://rt.cpan.org/NoAuth/ReportBug.html.


SUPPORT

You can find this documentation for this module with the perldoc command.


    perldoc CSS::Moonfall

You can also look for information at:


COPYRIGHT AND LICENSE

Copyright 2007 Shawn M Moore.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy