CSS-Prepare

 view release on metacpan or  search on metacpan

lib/CSS/Prepare/Property/Generated.pm  view on Meta::CPAN

package CSS::Prepare::Property::Generated;

use Modern::Perl;
use CSS::Prepare::Property::Expansions;
use CSS::Prepare::Property::Values;



sub parse {
    my $self        = shift;
    my $has_hack    = shift;
    my $location    = shift;
    my %declaration = @_;
    
    my $property = $declaration{'property'};
    my $value    = $declaration{'value'};
    my %canonical;
    my @errors;
    
    my $valid_property_or_error = sub {
            my $type  = shift;
            
            my $sub      = "is_${type}_value";
            my $is_valid = 0;
            
            eval {
                no strict 'refs';
                $is_valid = &$sub( $value );
            };
            
            if ( $is_valid ) {
                $canonical{ $property } = $value;
            }
            else {
                $type =~ s{_}{-}g;
                push @errors, {
                        error => "invalid ${type} property: '${value}'"
                    };
            }
            return $is_valid;
        };
    
    foreach my $type qw( content  quotes ) {
        &$valid_property_or_error( $type )
            if $type eq $property;
    }

    &$valid_property_or_error( 'counter_increment' )
        if 'counter-increment' eq $property;
    
    &$valid_property_or_error( 'counter_reset' )
        if 'counter-reset' eq $property;
    
    &$valid_property_or_error( 'list_style_type' )
        if 'list-style-type' eq $property;
    
    &$valid_property_or_error( 'list_style_image' )
        if 'list-style-image' eq $property;
    
    &$valid_property_or_error( 'list_style_position' )
        if 'list-style-position' eq $property;
    
    if ( 'list-style' eq $property ) {

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.432 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )