CSS-Tiny
view release on metacpan or search on metacpan
lib/CSS/Tiny.pm view on Meta::CPAN
}
.this {
color: red;
font-size: 10px;
}
P EM {
color: yellow;
}
When reading and writing, all property descriptors, for example C<color>
and C<font-size> in the example above, are converted to lower case. As an
example, take the following CSS.
P {
Font-Family: Verdana;
}
To get the value C<'Verdana'> from the object C<$CSS>, you should
reference the key C<$CSS-E<gt>{P}-E<gt>{font-family}>.
=head1 METHODS
=head2 new
The constructor C<new> creates and returns an empty C<CSS::Tiny> object.
=head2 read $filename
The C<read> constructor reads a CSS stylesheet, and returns a new
C<CSS::Tiny> object containing the properties in the file.
Returns the object on success, or C<undef> on error.
=head2 read_string $string
The C<read_string> constructor reads a CSS stylesheet from a string.
Returns the object on success, or C<undef> on error.
=head2 clone
The C<clone> method creates an identical copy of an existing C<CSS::Tiny>
object.
=head2 write_string
Generates the stylesheet for the object and returns it as a string.
=head2 write
The C<write $filename> generates the stylesheet for the properties, and
writes it to disk. Returns true on success. Returns C<undef> on error.
=head2 html
The C<html> method generates the CSS, but wrapped in a C<style> HTML tag,
so that it can be dropped directly onto a HTML page.
=head2 xhtml
The C<html> method generates the CSS, but wrapped in a C<style> XHTML tag,
so that it can be dropped directly onto an XHTML page.
=head2 errstr
When an error occurs, you can retrieve the error message either from the
C<$CSS::Tiny::errstr> variable, or using the C<errstr> method.
=head1 CAVEATS
=head2 CSS Rule Order
While the order of rules in CSS is important, this is one of the features
that is sacrificed to keep things small and dependency-free. If you need
to preserve order yourself, we recommend that you upgrade to the more
powerful L<CSS> module.
If this is not possible in your case, alternatively it can be done with the
help of another module such as L<Tie::IxHash>:
my $css = CSS::Tiny->new;
tie %$css, 'Tie::IxHash';
$css->read('style.css');
Note: You will also need to remember to add the additional dependency to
your code or module in this case.
=head1 SUPPORT
Bugs should be reported via the CPAN bug tracker at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CSS-Tiny>
For other issues, or commercial enhancement or support, contact the author.
=head1 AUTHOR
Adam Kennedy E<lt>adamk@cpan.orgE<gt>
=head1 SEE ALSO
L<CSS>, L<http://www.w3.org/TR/REC-CSS1>, L<Config::Tiny>, L<http://ali.as/>
=head1 COPYRIGHT
Copyright 2002 - 2010 Adam Kennedy.
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.
=cut
( run in 1.846 second using v1.01-cache-2.11-cpan-e1769b4cff6 )