CSS::Adaptor - Arbitrarily map CSS data for use in another context.


CSS documentation Contained in the CSS distribution.

Index


Code Index:

NAME

Top

CSS::Adaptor - Arbitrarily map CSS data for use in another context.

SYNOPSIS

Top

  use CSS;

  # create a CSS object with an adaptor
  my $css = new CSS({
       'adaptor' => 'CSS::Adaptor',
  });




  # load some CSS data
  $css->read_file( "my_file.css" );




  # change the adaptor
  $css->set_adaptor( "CSS::Adaptor::Pretty" );




  # output CSS object using the current adaptor
  print $css->output();




DESCRIPTION

Top

This class is used by CSS to translate a CSS object to a string. This allows CSS data to be easily mapped into other formats.

This documentation is for people who want to write their own CSS::Adaptor module. For usage information, see the documentation for CSS.

METHODS

Top

CONSTRUCTOR

new()

Called without options.

FUNCTIONS

output_rule( $rule )

returns a string containing a formatted CSS::Style object, passed as an object ref

output_selectors( $selectors )

returns a string containing a formatted list of CSS::Selector objects, passed as an array ref

output_properties( $properties )

returns a string containing a formatted list of CSS::Property objects, passed as an array ref

output_values( $values )

returns a string containing a formatted list of CSS::Value objects, passed as an array ref

AUTHORS

Top

Copyright (C) 2001-2002, Allen Day <allenday@ucla.edu>

Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com>

SEE ALSO

Top

CSS


CSS documentation Contained in the CSS distribution.

package CSS::Adaptor;

$VERSION = 1.01;

use strict;
use warnings;

use Carp qw(croak confess);

sub new {
	my $class = shift;
 	my $self = bless {}, $class;
	return $self;
}

sub output_rule {
	my ($self, $rule) = @_;
	return $rule->selectors.' { '.$rule->properties." }\n" ;
}

sub output_selectors {
	my ($self, $selectors) = @_;
	return join ', ', map {$_->{name}} @{$selectors}
}

sub output_properties {
	my ($self, $properties) = @_;
	return join '; ', map {$_->{property}.": ".$_->values} @{$properties};
}

sub output_values {
	my ($self, $values) = @_;
	return join '', map {$_->{value}} @{$values};
}

1;

__END__