CGI::Lazy::CSS - CGI::Lazy::CSS documentation


CGI-Lazy documentation Contained in the CGI-Lazy distribution.

Index


Code Index:

LEGAL

Top

SYNOPSIS

Top

	use CGI::Lazy;

	my $q = CGI::Lazy->new();




	print $q->header,

	      $q->css->load('somefile.css');




DESCRIPTION

CGI::Lazy::CSS is just a convience module for accessing css files.

METHODS

Top

dir ()

Returns directory containing css specified at lazy object creation

file (css)

Returns absolute path to file css parsed with document root and css directory

css

Css file name

load (file)

Reads file from css directory , wraps in script tags for output to browser

file

filename of cssfile

new ( q )

constructor.

q

CGI::Lazy object


CGI-Lazy documentation Contained in the CGI-Lazy distribution.

package CGI::Lazy::CSS;

use strict;

use CGI::Lazy::Globals;

#-------------------------------------------------------------------------------------------------
sub dir {
	my $self = shift;

	return $self->{_dir};
}

#----------------------------------------------------------------------------------------
sub file {
	my $self = shift;
	my $file = shift;

	my $dir = $self->dir;

	return "$dir/$file";
}

#----------------------------------------------------------------------------------------
sub load {
	my $self = shift;
	my $file = shift;
	
	my $dir = $self->dir;
	$dir =~ s/^\///; #strip a leading slash so we don't double it
	my $docroot = $ENV{DOCUMENT_ROOT};
	$docroot =~ s/\/$//; #strip the trailing slash so we don't double it

	open IF, "< $docroot/$dir/$file" or $self->q->errorHandler->couldntOpenCssFile($docroot, $dir, $file, $!);

	my $script;

	$script .= $_ while <IF>;

	close IF;

	return $self->q->csswrap($script);

}

#-------------------------------------------------------------------------------------------------
sub new {
	my $class = shift;
	my $q = shift;

	return bless {
		_q 		=> $q,
		_dir		=> $q->config->cssDir,
	
	}, $class;
}

#-------------------------------------------------------------------------------------------------
sub q {
	my $self = shift;

	return $self->{_q};
}

1

__END__