NAME

CSS::Object::Format - CSS Object Oriented Stringificator for Inline CSS

SYNOPSIS

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 );

VERSION

v0.1.0

DESCRIPTION

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

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.

CONSTRUCTOR

new

To instantiate a new CSS::Object::Format object, pass an hash reference of following parameters:

debug

This is an integer. The bigger it is and the more verbose is the output.

METHODS

rule_as_string

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 );

comment_as_string

This returns a formatted comment string.

rule_as_string

This returns a css rule as string.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

CSS::Object

COPYRIGHT & LICENSE

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.