codeigniter-css by Serafim Junior Dos Santos Fagundes Cyb3r Network

Version 1.0.2

MIT License

Copyright (c) 2010 Serafim Junior Dos Santos Fagundes Cyb3r Network


codeigniter-css is a library for the CodeIgniter framework. Its goal is to 
generate CSS block and inline statements in PHP. Its use aleviates the
programmer's burden of switching paradigms when coding and letting him focus in 
one language easing code maintenance also.

Load the library in the controller.

	# Showing default parameter value
	$params = array( 'version' => 2.1 );

	$this->load->library( 'css', $params );

The following example uses codeigniter-xhtml for the insertion of the style tag.

	# Create a style object with a selector
	$style = $this->css->select( 'h1' );

	# Add style
	$style->color( 'red' );

	# Append style (in this case) to an xhtml style element
	$style = $this->xhtml->style( $style->generate() );

	# Append to head; 
	$this->xhtml->head( $style );

Or if you want CSS file creation (by caching) with link tag generation

	# Declare a selector
	$this->css->select( 'body' );

	# Add style
	$this->css->style->background_color( '#666' );

	# Cache style declarations
	$file = './my/file.css';
	$this->css->cache( $file );

	# Generate link
	$link = $this->css->link();

	# Append to head
	$this->xhtml->head( $link );

If you want an inline style statement...

	$il_style = $this->css->inline();

	$il_style->background_color( '#666' );
	$il_style->color( '#FFF' );

	$attrs = array( 'style' => $il_style->generate() );

	$this->xhtml->div( 'I\'m a div!', $attrs );