233,741 Installs and Counting! Get Sparks Now!
Hey! Keep up to date with the project through its beta and public launch by following @getsparks.
Tweet
A Quick Looks At Sparks (EllisLab Official Post)
March 11, 2012
from: codeigniter.com
The Top Sparks of 2011
December 31, 2011
from: codefury.net
CodeIgniter Starter Project − A Starting Point for Any CI Dev
December 12, 2011
from: github.com
NetTuts+ Tutorial for GetSparks
November 24, 2011
from: net.tutsplus.com
haml & sass rendering spark for CI from phamlp library
| Contributor | : dperrymorrow |
| : Log in to view | |
| Author Website | : http://www.newfinds.com |
| Spark Website | : https://github.com/dperrymorrow/haml_sass |
| Repository Type | : git |
| Number of Installs | : 1,251 |
php tools/spark install -v1.0.0 haml_sass
Or download this version manually:
Get haml_sass-1.0.0.zip
Thanks to Phamlp this is available to PHP projects.
What is Haml & Sass?
Haml and Sass have been used in Ruby for sometime to simplify templates (Haml) and make CSS more intelligent, flexible and manageable (Sass); now they come to PHP in PHamlP.
Most of the configuration variables are self explanatory.
The haml parser options can be fully explored here haml parser options
The sass parser options can be fully explored here sass parser options
One item that probally needs explanation is the sass_dir variable. This is where sass will look for sass files that are included into other sass files using the @include operator. This is also the director that the sass_router will look for your sass files when bypassing Codeigniter entirely with a pre_system hook should you use that method of loading your sass files.
$config['sass']['sass_dir'] = APPPATH.'views/sass';
function haml_test()
{
// load the spark (x.x represents the version)
$this->load->spark( 'haml_sass/x.x');
// set your data like you would for any view
$data['server'] = $_SERVER;
// specify your haml file to render
$this->haml_sass->parse_haml( 'haml_test.haml', $data );
}
If you would like the output returned as a string, specify the optional third parameter to true,
$output = $this->haml_sass->parse_haml( 'haml_test.haml', $data, TRUE );
There are two ways to render your sass.
// load the spark
$this->load->spark( 'haml_sass/x.x');
// parse and output your sass file
$this->haml_sass->parse_sass( 'sass/sass_test.sass' );
In sparks/haml_sass/x.x/config/haml_sass.php config file you will find an example hook to paste into your hooks. Place this code snippet into your application/config/hooks.php file.
You must have hooks enabled in your application/config/config.php file for this to work.
$config['enable_hooks'] = TRUE;
Now place the snipped you got from the haml_sass.php config file into your application/config/hooks.php file. Be sure to change 1.0 to whatever the current version of the spark is.
$hook['pre_system'] = array(
'class' => 'Sass_router',
'function' => 'check_for_sass',
'filename' => 'sass_router.php',
'filepath' => '../sparks/haml_sass/1.0/libraries',
'params'=>array()
);
Now you need to specify the router trigger that will fire the sass router to look for a sass file instead of a CI controller/action. In sparks/haml_sass/x.x/config/haml_sass.php config file you will see the variable router_trigger, this is the string that will trigger the sass router.
$config['sass']['router_trigger'] = 'css';
now when you hit your app at http://sparks.local:8888/index.php/css/sasstest.sass your sass router will look for sasstest.sass and render it, if not found it will 404. This is all run before all the overhead of Codeigniter.
When using the sass router method of loading sass, the spark has a helper for you to make your link tags. There is no need to load it, its autoloaded with the spark. It is very similar to the html link_tag helper method.
sass_link( $file, $rel='stylesheet', $type='text/css', $media='print' )
php tools/spark install -v1.0.0 haml_sass
Or download this version manually:
Get haml_sass-1.0.0.zip