NAME

Sumi::CSS::Rule - A single CSS rule node for Sumi::CSS

SYNOPSIS

use Sumi::CSS::Rule;

my $rule = Sumi::CSS::Rule->new(
    selector => ['.foo'],
    style    => 'color: red;'
);

say $rule->type;           # "style"
say $rule->to_string;      # ".foo color: red;"

DESCRIPTION

Sumi::CSS::Rule represents a single CSS rule, at-rule, or nested block, with type introspection and formatting utilities.

ATTRIBUTES

selector

my $sel = $rule->selector;
$rule->selector(['.foo', '.bar']);

An array reference of selector strings.

style

my $style = $rule->style;
$rule->style('color: red;');

A string or array reference representing the CSS style body. In the case of nested at-rules, this may contain more Sumi::CSS::Rule objects.

METHODS

type

my $type = $rule->type;

Returns the rule type, one of:

  • style — a normal CSS selector rule

  • statement_at — a statement-level at-rule (e.g. @import)

  • block_at — a block-level at-rule (e.g. @media)

to_string

my $text = $rule->to_string;
my $text = $rule->to_string($indent_level, $indent_depth);

Returns the formatted CSS representation of this rule, optionally with indentation control.

to_string_ugly

my $text = $rule->to_string_ugly;

Returns a less formatted version of the rule, mainly used internally.

localized

my $localized_rule = $rule->localized('.en');

Returns a deep-cloned copy of the rule with all selectors localized by prefixing them with the provided string.

SEE ALSO

Sumi::CSS

AUTHOR

Simone Cesano <scesano@cpan.org>

LICENSE

This module is released under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 146:

Non-ASCII character seen before =encoding in '—'. Assuming UTF-8