CSS-Simple
view release on metacpan or search on metacpan
NAME
CSS::Simple - Interface through which to read/write/manipulate CSS files
while respecting the cascade order
SYNOPSIS
use CSS::Simple;
my $css = new CSS::Simple();
$css->read_file({ filename => 'input.css' });
#perform manipulations...
$css->write_file({ filename => 'output.css' });
DESCRIPTION
Class for reading, manipulating and writing CSS. Unlike other CSS
classes on CPAN this particular module focuses on respecting the order
of selectors while providing a common sense API through which to
manipulate the rules.
Please note that while ordering is respected, the exact order of
selectors may change. I.e. the rules implied by the styles and their
ordering will not change, but the actual ordering of the styles may
shift around. See the read method for more information.
CONSTRUCTOR
new ([ OPTIONS ])
Instantiates the CSS::Simple object. Sets up class variables that
are used during file parsing/processing.
warns_as_errors (optional). Boolean value to indicate whether fatal
errors should occur during parse failures.
METHODS
read_file( params )
Opens and reads a CSS file, then subsequently performs the parsing
of the CSS file necessary for later manipulation.
This method requires you to pass in a params hash that contains a
filename argument. For example:
$self->read_file({filename => 'myfile.css'});
read( params )
Reads css data and parses it. The intermediate data is stored in
class variables.
Compound selectors (i.e. "a, span") are split apart during parsing
and stored separately, so the output of any given stylesheet may not
match the output 100%, but the rules themselves should apply as
expected.
Ordering of selectors may shift if the same selector is seen twice
within the stylesheet. The precendence for any given selector is the
last time it was seen by the parser.
This method requires you to pass in a params hash that contains
scalar css data. For example:
$self->read({css => $css});
write_file()
( run in 0.393 second using v1.01-cache-2.11-cpan-e93a5daba3e )