.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "CSS::Tiny 3pm" .TH CSS::Tiny 3pm "2016-03-14" "perl v5.22.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CSS::Tiny \- Read/Write .css files with as little code as possible .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& # In your .css file \& H1 { color: blue } \& H2 { color: red; font\-family: Arial } \& .this, .that { color: yellow } \& \& # In your program \& use CSS::Tiny; \& \& # Create a CSS stylesheet \& my $CSS = CSS::Tiny\->new(); \& \& # Open a CSS stylesheet \& $CSS = CSS::Tiny\->read( \*(Aqstyle.css\*(Aq ); \& \& # Reading properties \& my $header_color = $CSS\->{H1}\->{color}; \& my $header2_hashref = $CSS\->{H2}; \& my $this_color = $CSS\->{\*(Aq.this\*(Aq}\->{color}; \& my $that_color = $CSS\->{\*(Aq.that\*(Aq}\->{color}; \& \& # Changing styles and properties \& $CSS\->{\*(Aq.newstyle\*(Aq} = { color => \*(Aq#FFFFFF\*(Aq }; # Add a style \& $CSS\->{H1}\->{color} = \*(Aqblack\*(Aq; # Change a property \& delete $CSS\->{H2}; # Delete a style \& \& # Save a CSS stylesheet \& $CSS\->write( \*(Aqstyle.css\*(Aq ); \& \& # Get the CSS as a tag \& $CSS\->html; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`CSS::Tiny\*(C'\fR is a perl class to read and write .css stylesheets with as little code as possible, reducing load time and memory overhead. \s-1CSS\s0.pm requires about 2.6 meg or ram to load, which is a large amount of overhead if you only want to do trivial things. Memory usage is normally scoffed at in Perl, but in my opinion should be at least kept in mind. .PP This module is primarily for reading and writing simple files, and anything we write shouldn't need to have documentation/comments. If you need something with more power, move up to \s-1CSS\s0.pm. With the increasing complexity of \s-1CSS,\s0 this is becoming more common, but many situations can still live with simple \s-1CSS\s0 files. .SS "\s-1CSS\s0 Feature Support" .IX Subsection "CSS Feature Support" \&\f(CW\*(C`CSS::Tiny\*(C'\fR supports grouped styles of the form \&\f(CW\*(C`this, that { color: blue }\*(C'\fR correctly when reading, ungrouping them into the hash structure. However, it will not restore the grouping should you write the file back out. In this case, an entry in the original file of the form .PP .Vb 1 \& H1, H2 { color: blue } .Ve .PP would become .PP .Vb 2 \& H1 { color: blue } \& H2 { color: blue } .Ve .PP \&\f(CW\*(C`CSS::Tiny\*(C'\fR handles nested styles of the form \f(CW\*(C`P EM { color: red }\*(C'\fR in reads and writes correctly, making the property available in the form .PP .Vb 1 \& $CSS\->{\*(AqP EM\*(Aq}\->{color} .Ve .PP \&\f(CW\*(C`CSS::Tiny\*(C'\fR ignores comments of the form \f(CW\*(C`/* comment */\*(C'\fR on read correctly, however these comments will not be written back out to the file. .SH "CSS FILE SYNTAX" .IX Header "CSS FILE SYNTAX" Files are written in a relatively human-orientated form, as follows: .PP .Vb 10 \& H1 { \& color: blue; \& } \& .this { \& color: red; \& font\-size: 10px; \& } \& P EM { \& color: yellow; \& } .Ve .PP When reading and writing, all property descriptors, for example \f(CW\*(C`color\*(C'\fR and \f(CW\*(C`font\-size\*(C'\fR in the example above, are converted to lower case. As an example, take the following \s-1CSS.\s0 .PP .Vb 3 \& P { \& Font\-Family: Verdana; \& } .Ve .PP To get the value \f(CW\*(AqVerdana\*(Aq\fR from the object \f(CW$CSS\fR, you should reference the key \f(CW\*(C`$CSS\->{P}\->{font\-family}\*(C'\fR. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" The constructor \f(CW\*(C`new\*(C'\fR creates and returns an empty \f(CW\*(C`CSS::Tiny\*(C'\fR object. .ie n .SS "read $filename" .el .SS "read \f(CW$filename\fP" .IX Subsection "read $filename" The \f(CW\*(C`read\*(C'\fR constructor reads a \s-1CSS\s0 stylesheet, and returns a new \&\f(CW\*(C`CSS::Tiny\*(C'\fR object containing the properties in the file. .PP Returns the object on success, or \f(CW\*(C`undef\*(C'\fR on error. .ie n .SS "read_string $string" .el .SS "read_string \f(CW$string\fP" .IX Subsection "read_string $string" The \f(CW\*(C`read_string\*(C'\fR constructor reads a \s-1CSS\s0 stylesheet from a string. .PP Returns the object on success, or \f(CW\*(C`undef\*(C'\fR on error. .SS "clone" .IX Subsection "clone" The \f(CW\*(C`clone\*(C'\fR method creates an identical copy of an existing \f(CW\*(C`CSS::Tiny\*(C'\fR object. .SS "write_string" .IX Subsection "write_string" Generates the stylesheet for the object and returns it as a string. .SS "write" .IX Subsection "write" The \f(CW\*(C`write $filename\*(C'\fR generates the stylesheet for the properties, and writes it to disk. Returns true on success. Returns \f(CW\*(C`undef\*(C'\fR on error. .SS "html" .IX Subsection "html" The \f(CW\*(C`html\*(C'\fR method generates the \s-1CSS,\s0 but wrapped in a \f(CW\*(C`style\*(C'\fR \s-1HTML\s0 tag, so that it can be dropped directly onto a \s-1HTML\s0 page. .SS "xhtml" .IX Subsection "xhtml" The \f(CW\*(C`html\*(C'\fR method generates the \s-1CSS,\s0 but wrapped in a \f(CW\*(C`style\*(C'\fR \s-1XHTML\s0 tag, so that it can be dropped directly onto an \s-1XHTML\s0 page. .SS "errstr" .IX Subsection "errstr" When an error occurs, you can retrieve the error message either from the \&\f(CW$CSS::Tiny::errstr\fR variable, or using the \f(CW\*(C`errstr\*(C'\fR method. .SH "CAVEATS" .IX Header "CAVEATS" .SS "\s-1CSS\s0 Rule Order" .IX Subsection "CSS Rule Order" While the order of rules in \s-1CSS\s0 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 \s-1CSS\s0 module. .PP If this is not possible in your case, alternatively it can be done with the help of another module such as Tie::IxHash: .PP .Vb 3 \& my $css = CSS::Tiny\->new; \& tie %$css, \*(AqTie::IxHash\*(Aq; \& $css\->read(\*(Aqstyle.css\*(Aq); .Ve .PP Note: You will also need to remember to add the additional dependency to your code or module in this case. .SH "SUPPORT" .IX Header "SUPPORT" Bugs should be reported via the \s-1CPAN\s0 bug tracker at .PP .PP For other issues, or commercial enhancement or support, contact the author. .SH "AUTHOR" .IX Header "AUTHOR" Adam Kennedy .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1CSS\s0, , Config::Tiny, .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2002 \- 2010 Adam Kennedy. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP The full text of the license can be found in the \&\s-1LICENSE\s0 file included with this module.