CSS-Object

 view release on metacpan or  search on metacpan

lib/CSS/Object/Format.pm  view on Meta::CPAN

        close_brace_on_new_line
        indent
        new_line
        open_brace_and_new_line
        open_brace_on_new_line
        property_separator
    )];
    return( $self );
}

sub backup_parameters { return( shift->clone ); }

sub class { return( ref( $_[0] ) ); }

sub close_brace_on_new_line { return( shift->_set_get_boolean( 'close_brace_on_new_line', @_ ) ); }

sub comment_as_string
{
    my( $self, $elem ) = @_;
    # no overloading;
    return( $self->error( "No comment object was provided." ) ) if( !defined( $elem ) );

lib/CSS/Object/Format.pm  view on Meta::CPAN

=item * L</open_brace_and_new_line>

=item * L</indent>

=item * L</property_separator>

=back

=head1 METHODS

=head2 backup_parameters

This will create a deep copy of this formatter's L</parameters> and return it.

See L</restore_parameters>

=head2 close_brace_on_new_line

This takes a boolean value. If true, this will instruct the formatter to place the closing brace on a new line.

=head2 comment_as_string

lib/CSS/Object/Format.pm  view on Meta::CPAN

=head2 property_separator

This sets or gets the property separator. By default, this is a new line C<\n>

If you want the formatter to put all properties on a single line, you could replace this default value with an empty string.

This returns the current character value as a L<Module::Generic::Scalar> object.

=head2 restore_parameters

Provided with an hash reference, typically that created by L</backup_parameters> and this will restore this formatter's L</parameters>

It returns our object

=head2 rule_as_string

Provided with a L<CSS::Object::Rule> object and this will format it and return its string representation.

=head2 selectors_as_string

Provided with an array reference of a L<CSS::Object::Selector> objects and this will format them and return their string representation.

lib/CSS/Object/Format/Inline.pm  view on Meta::CPAN

    {
        $self->$_( $fmt->$_ ) if( $fmt->can( $_ ) );
    }
    return( $self );
}

sub elements_as_string
{
    my( $self, $elems ) = @_;
    no overloading;
    ## Make a backup of parameters and we'll restore them after
    my $backup = $self->backup_parameters;
    ## new_array() from Module::Generic
    my $all = $backup->{elements} = $self->new_array;
    $elems->foreach(sub
    {
        $all->push( $_->format->backup_parameters );
        $_->format->indent( '' );
        $_->format->property_separator( ' ' );
    });
    
    $self->property_separator( ' ' );
    $self->indent( '' );
    my $res = $self->SUPER::elements_as_string( $elems );
    $self->restore_parameters( $backup );
    $elems->for(sub
    {
        my( $i, $this ) = @_;
        $this->format->restore_parameters( $all->get( $i ) );
    });
    return( $res );
}

sub rule_as_string
{



( run in 1.261 second using v1.01-cache-2.11-cpan-49f99fa48dc )