Kevin Hatim Kamel > CSS-Inliner-3901 > CSS::Inliner::Parser

Download:
CSS-Inliner-3901.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  3
View/Report Bugs
Module Version: 1   Source   Latest Release: CSS-Inliner-3948

NAME ^

CSS::Inliner::Parser - Interface through which to read/write CSS files while respecting the cascade order

NOTE: This sub-module very seriously focuses on respecting cascade order. As such this module is not for you if you want to modified a stylesheet once it's read. If you are looking for that functionality you may want to look at the sister module, CSS::Simple

SYNOPSIS ^

 use CSS::Inliner::Parser;

 my $css = new CSS::Inliner::Parser();

 $css->read({ filename => 'input.css' });

 #perform manipulations...

 $css->write({ filename => 'output.css' });

DESCRIPTION ^

Class for reading and writing CSS. Unlike other CSS classes on CPAN this particular module focuses on respecting the order of selectors. This is very useful for things like... inlining CSS, or for similar "strict" CSS work.

CONSTRUCTOR ^

new ([ OPTIONS ])

Instantiates the CSS::Inliner::Parser 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.

This method requires you to pass in a params hash that contains scalar css data. For example:

$self->read({css => $css});

write_file()

Write the parsed and manipulated CSS out to a file parameter

This method requires you to pass in a params hash that contains a filename argument. For example:

$self->write_file({filename => 'myfile.css'});

write()

Write the parsed and manipulated CSS out to a scalar and return it

content_warnings()

Return back any warnings thrown while parsing a given block of css

Note: content warnings are initialized at read time. In order to receive back content feedback you must perform read() first.

get_entries( params )

Get an array of entries representing the composition of the stylesheet. These entries are returned in the exact order that they were discovered.

An entry is composed of a hash with a structure like the following:

$entry = { selector => '.my_selector', properties => { attribute => 'value' } }

add_entry( params )

Add an entry containing a selector and associated properties to the stored rulesets

This method requires you to pass in a params hash that contains scalar css data. For example:

$self->add_entry({selector => '.foo', properties => {color => 'red' }});

Sponsor ^

This code has been developed under sponsorship of MailerMailer LLC, http://www.mailermailer.com/

AUTHOR ^

Kevin Kamel <kamelkev@mailermailer.com>

ATTRIBUTION ^

This module is directly based off of Adam Kennedy's <adamk@cpan.org> CSS::Tiny module.

This particular version differs in terms of interface and the ultimate ordering of the CSS.

LICENSE ^

This module is a derived version of Adam Kennedy's CSS::Tiny Module.

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

The full text of the license can be found in the LICENSE file included with this module.

syntax highlighting: