CSS::Ob...Builder(3)

πŸ“¦ version 0.2.0, in alpine 3.24

πŸ’… CSS::Ob...Builder(3) β€” CSS Object Oriented Builder ✨

okay so this is the Perl doc page for CSS::Object::Builder, and yes the manual name got a little truncated in the header (CSS::Ob...Builder(3)) but bestie, it's fine, we know what it is 🫢 β€” it's a User Contributed Perl Documentation page and it's genuinely serving.


🌸 NAME 🌸

CSS::Object::Builder β€” the CSS Object Oriented Builder, no cap πŸ’…


✨ SYNOPSIS ✨

like, just look at her go:

use CSS::Object;
my $css = CSS::Object->new( debug => 3 ) ||
    die( CSS::Object->error );
my $b = $css->builder;
$b->select( ['#main_section > .article', 'section .article'] )
    ->display( 'none' )
    ->font_size( '+0.2rem' )
    ->comment( ['Some multiline comment', 'that are made possible with array reference'] )
    ->text_align( 'center' )
    ->comment( 'Making it look pretty' )
    ->padding( 5 );
$b->charset( 'UTF-8' );
$b->at( _webkit_keyframes => 'error' )
    ->frame( 0, { _webkit_transform => 'translateX( 0px )' })
    ->frame( 25, { _webkit_transform => 'translateX( 30px )' })
    ->frame( 45, { _webkit_transform => 'translateX( -30px )' })
    ->frame( 65, { _webkit_transform => 'translateX( 30px )' })
    ->frame( 82, { _webkit_transform => 'translateX( -30px )' })
    ->frame( 94, { _webkit_transform => 'translateX( 30px )' })
    ->frame( [qw( 35 55 75 87 97 100 )], { _webkit_transform => 'translateX( 0px )' } );

the chaining? iconic. the keyframes? ate. periodt πŸ”₯


πŸŽ€ VERSION πŸŽ€

v0.2.0

πŸ¦‹ DESCRIPTION πŸ¦‹

CSS::Object::Builder is a dynamic object oriented CSS builder. that's the whole vibe. it builds CSS, dynamically, in an object oriented way. πŸ’–


πŸ‘‘ CONSTRUCTOR πŸ‘‘

🌈 new

to instantiate a new CSS::Object::Builder object you need to pass it a CSS::Object object and that's it. literally it. that's the whole requirement bestie.

optional argument is:

  • debug β€” this is an integer. the bigger it is and the more verbose is the output. that's the tradeoff, you get more tea spilled but you also get more πŸ“

πŸ’œ METHODS πŸ’œ

⭐ as_string

this is a shorthand for calling "as_string" in CSS::Object using our "css" method. cute little shortcut, we love a shortcut 🫢

πŸ“ at

this takes an at-mark type parameter as first argument, and the name of the at-mark rule. it returns an object from the proper class. for example, a @keyframes rule would return a CSS::Object::Rule::Keyframes. it's giving "right object for the right job" energy ✨

🌸 charset

this takes an encoding as unique argument, and no matter when it is called in the chain of method calls, this will always be placed at the top of the stylesheet. she always gets first place, main character energy fr fr πŸ‘‘

🧚 comment

provided with a string or an array reference of comment lines, and this will return an CSS::Object::Comment object. leave a little note for your future self πŸ’Œ

πŸ’… css

this sets or gets the required CSS::Object for this parser. the parser uses this method and the underlying object to access CSS::Object methods and store css rules using "add_element" in CSS::Object. it's the whole backbone of the operation ngl

πŸ”₯ current_rule

returns the last added rule from CSS::Object list of rules by calling "last" in Module::Generic::Array on "elements" in CSS::Object which returns a Module::Generic::Array object. newest rule, front of the line, we see her πŸ’«

πŸ™ˆ elements

sets or gets the list of css elements. this is a Module::Generic::Array, but is not used. I should remove it. yes that's literally what the docs say, bestie is being honest with us 😭 we respect the transparency.

🌈 new_at_rule

this creates and returns a new CSS::Object::Builder::AtRule object. this should be moved under CSS::Object. noted, filed away, we'll get to it (we won't) πŸ“‹

πŸ¦‹ new_keyframes_rule

this creates and returns a new CSS::Object::Builder::KeyframesRule-object. this should be moved under CSS::Object. same energy, same promise πŸ’€

✨ new_rule

this creates and returns a new CSS::Object::Builder::Rule object. CSS::Object::Builder::Rule class allos for dynamic method call to create and add css properties inside a css rule. (yes "allos" is a typo in the original, we're keeping it, it's part of the lore πŸŽ€)

πŸ’– select

this takes either a css selector as a string or an array reference of css selectors. it then returns a CSS::Object::Builder::Rule, which is a special class with dynamic method using AUTOLOAD. this makes it possible to call the hundred of css property as method. a hundred. hundredsss. obsessed 😍

since those css properties are called as perl method, dashes have to be expressed as underline, such as:

$b->select( '.my-class' )->_moz_transition( 'all .25s ease' );

this would be interpreted as:

.my-class
{
    -moz-transition: all .25s ease;
}
no cap: the dash-to-underline swap is not optional. if you write the dash, it will not work the way you want. translate accordingly bestie πŸ’…

🫢 AUTHOR 🫢

Jacques Deguest <jack@deguest.jp>


⭐ SEE ALSO ⭐

  • 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. slay, go wild, just keep the terms 🌸


and that's the page!! πŸŽ€ sign-off time: this was perl v5.42.2, dated 2026-02-15, and the manual name up top is CSS::Ob...Builder(3) β€” truncated but thriving. mwah πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from