NAME
CSS::Object::Value - CSS Object Oriented Value
SYNOPSIS
use
CSS::Object::Value;
# For font-size property for example
my
$val
= CSS::Object::Value->new(
'1.2rem'
,
debug
=> 3,
format
=>
$format_object
,
) ||
die
( CSS::Object::Value->error );
# Adding value with comment inside
my
$val
= CSS::Object::Value->new(
'1.2rem'
,
with_comment
=>
{
before
=>
'This is 12px'
,
after
=> [
"Might want to change this"
,
"to something else"
],
}) ||
die
(
"Cannot add value with comments: "
, CSS::Object::Value->error );
my
$val
= CSS::Object::Value->new(
'/* Might need to change this */ 1.2rem /* Maybe move this to px instead? */'
,
debug
=> 3,
format
=>
$format_object
,
) ||
die
( CSS::Object::Value->error );
# or
$val
->comment_before->
push
(
$css
->new_comment(
"More comment before value"
));
#val->comment_after->push( $css->new_comment( "Another comment after too" ));
# or
$val
->with_comment({
before
=>
'This is 12px'
,
after
=> [
"Might want to change this"
,
"to something else"
],
}) ||
die
(
$val
->error );
VERSION
v0.2.0
DESCRIPTION
CSS::Object::Value is a module to contain the CSS properties' value.
CONSTRUCTOR
new
To instantiate a new CSS::Object::Value object, pass an hash reference of following parameters:
- debug
-
This is an integer. The bigger it is and the more verbose is the output.
- format
-
This is a CSS::Object::Format object or one of its child modules.
- value
-
The property value, which can also be called as the sole argument:
# For display property for example
my
$val
= CSS::Object::Value->new(
'none'
);
- with_comment
-
This parameter must be an hash reference with 2 possible properties: before and after. Each of thoe properties can contain either a simple string, an array reference of string, or an CSS::Object::Comment object.
It returns our object
METHODS
as_string
This calls the "format" and its method "value_as_string" in CSS::Object::Format
It returns the css string produce or undef and sets an Module::Generic::Exception upon error.
format
This is a CSS::Object::Format object or one of its child modules.
value
Sets or gets the value for this property value. The value stored here becomes a Module::Generic::Scalar and thus all its object methods can be used
Alternatively, it accepts a CSS::Object::Value and will call its "value" method to get the actual string to store.
It returns the value currently stored.
with_comment
This method takes an hash reference with 2 possible properties: before and after. Each of thoe properties can contain either a simple string, an array reference of string, or an CSS::Object::Comment object.
It returns the object used to call this method, or undef if there was an error.
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
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.