CSS::Object::Format - CSS Object Oriented Stringificator for Inline CSS
use CSS::Object::Format::Inline; my $format = CSS::Object::Format::Inline->new( debug => 3 ) || die( CSS::Object::Format::Inline->error ); my $prop = CSS::Object::Property->new( format => $format, debug => 3, name => 'display', value => 'inline-block', ) || die( CSS::Object::Property->error ); print( $prop->as_string );
v0.1.0
CSS::Object::Format is a object oriented CSS parser and manipulation interface to write properties suitable to be added inline, i.e. inside an html element attribute style. This package inherits from CSS::Object::Format
style
Because it is designed to be inline, there cannot be multiple rules. There is only rule and is implicit and used solely to hold all the properties.
To instantiate a new CSS::Object::Format object, pass an hash reference of following parameters:
This is an integer. The bigger it is and the more verbose is the output.
Provided with a CSS::Object::Rule object and this will format it and return its string representation suitable for inline use in an HTML element.
my $css = CSS::Object->new( debug => 3, format => CSS::Object::Format::Inline->new( debug => 3 ) ); my $rule = $css->add_rule( $css->new_rule ); $rule->add_property( $css->new_property( name => 'display', value => 'none', )); $rule->add_property( $css->new_property( name => 'font-size', value => '1.2rem', )); $rule->add_property( $css->new_property( name => 'text-align', value => 'center', )); print( '<div style="%s"></div>', $rule->as_string );
This returns a formatted comment string.
This returns a css rule as string.
Jacques Deguest <jack@deguest.jp>
CSS::Object
Copyright (c) 2020 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
To install CSS::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CSS::Object
CPAN shell
perl -MCPAN -e shell install CSS::Object
For more information on module installation, please visit the detailed CPAN module installation guide.