peteboere / css-crush

CSS preprocessor.
http://the-echoplex.net/csscrush
MIT License
537 stars 51 forks source link

Documentation on Plugin API #57

Closed dubcanada closed 9 years ago

dubcanada commented 10 years ago

Hello,

It's pretty easy to read the current plugins and get an general sense for what you need to do to build a plugin, but it would be nice to have documentation on it.

losttheplot commented 9 years ago

Hi; great project, but how do you instal or initiate a plugin, please? Also, how do you set an option? Neither of these attempts work - what should I do please?

<?php
require_once 'crush/CssCrush.php';
csscrush_set('options', array('minify'=>'false')); // this has no effect.
csscrush_set('config', array('plugins'=>'loop')); // this is a wild guess at how to initiate a plugin.
?>
losttheplot commented 9 years ago

OK, so you initialise one or more plugins as follows:

require_once 'crush/CssCrush.php';
csscrush_set('options', array('minify'=>'false'));
csscrush_set('options', array('plugins'=> array('color', 'loop')));

But what was throwing me is that the minify setting above is having no effect on the output i.e. the resultant css file is minified, despite csscrush_get('options', 'minify') showing as 'false'.

peteboere commented 9 years ago

csscrush_set() is for setting defaults, it's better to pass in the options you want when you're calling one of the compile functions:

echo csscrush_tag('styles.css', $options);
losttheplot commented 9 years ago

Oh I see, thank you, although this still does not un-minify the output, so I'm obviously not getting it right with either of these attempts:

echo csscrush_tag('css/styles_crush.css', array('minify'=>'false'));
echo csscrush_tag('css/styles_crush.css', array('options'=> array('minify'=>'false')));
peteboere commented 9 years ago
echo csscrush_tag('css/styles_crush.css', array('minify'=>'false'));

Is the correct way, but it works for me...

losttheplot commented 9 years ago

This is exactly what I'm using, but the output is one solid block of css text i.e. not minified. Ho hum! ...not the end of the world tho'. Thanks :)

require_once 'crush/CssCrush.php';
csscrush_set('options', array('plugins'=> array('color', 'loop')));
$css_tag = csscrush_tag('css/styles_crush.css', array('minify'=>'false'));
peteboere commented 9 years ago

Ah, false should be the keyword, not a string

$css_tag = csscrush_tag('css/styles_crush.css', array('minify'=> false)); 
losttheplot commented 9 years ago

Ah, yes, that's better. Thank you :)

I'm very impressed with css-crush; specifically the plugins such as the ability to create colour keywords.