richthegeek / phpsass

A compiler for SASS/SCSS written in PHP, brought up to date (approx 3.2) from a fork of PHamlP: http://code.google.com/p/phamlp/
http://phpsass.com/
382 stars 83 forks source link

Compass partials #1

Open tsi opened 12 years ago

tsi commented 12 years ago

I don't see any of compass's partials included here, should I take them from somewhere else ? I'm used to other phamlp forks including them under /extensions. thanks.

richthegeek commented 12 years ago

I thought we covered this last night?

Including compass and other frameworks in the PHamlP core is wrong - it limits user choice on what libraries/frameworks to use and increases download size.

Compass and all other frameworks can be included by creating a callback function in the config option array "load_path_functions". Whenever a file is loaded it's path is passed to this function and it can return an array containing 0+ correct files to load in place. For example, "compass/css3" should get translated to "/path/to/compass/css3/_css3.scss".

Take a look at http://drupalcode.org/project/sassy.git/blob/632c9c15edd38694d55916fd686ac189c4f8f0a0:/extensions/compass/sassy_compass.module for an example function.

Compass is a little more complicated as it also includes additional functions - these are defined in the included files above , and then included in sassy by adding to the config option array "functions" (which the linked file does by proxy).

Doing it this way does make it a bit more complicated to add compass to your setup but it is the /correct/ way of doing it because it doesn't increase bloat and decrease choice like including it in /extensions/ does.

WRT including it in a Drupal module, just say "requires Sassy".

tsi commented 12 years ago

Apologies, but it's still not really clear to me. This is what I know : Compass for me is a bunch of partials, now you say it also includes additional functions, I will keep that in mind but what interests me is the partials (or can't I ignore those functions ?). Now, I do pass an array into 'load_paths' and compass (sassy's extensions dir) is included in this array. The error I get, and I'm not even sure this is related is :

Notice: Trying to get property of non-object in SassNode->getFilename() (line 232 of /var/www/drupal-7.10/sites/all/themes/sasson/phamlp/tree/SassNode.php).
Notice: Trying to get property of non-object in SassNode->getLine() (line 208 of /var/www/drupal-7.10/sites/all/themes/sasson/phamlp/tree/SassNode.php).
Notice: Trying to get property of non-object in SassNode->getSource() (line 192 of /var/www/drupal-7.10/sites/all/themes/sasson/phamlp/tree/SassNode.php).
tsi commented 12 years ago

I can push this version of sasson in a different branch if you ever want to take a look at what we're doing.

richthegeek commented 12 years ago

You can't ignore those functions - they are available in existing branches of PhamlP through roughly the same method as we are using although without the extensibility.

Either using the existing extension method or the pluggable function list, the functions must be included for compass to function.

If you can push your code that's causing those notices to github that'd be useful for tracking down why it fails.

On 17 January 2012 09:37, Tsachi Shlidor < reply@reply.github.com

wrote:

Apologies, but it's still not really clear to me. This is what I know : Compass for me is a bunch of partials, now you say it also includes additional functions, I will keep that in mind but what interests me is the partials (or can't I ignore those functions ?). Now, I do pass an array into 'load_paths' and compass (sassy's extensions dir) is included in this array. The error I get, and I'm not even sure this is related is :

Notice: Trying to get property of non-object in SassNode->getFilename()
(line 232 of
/var/www/drupal-7.10/sites/all/themes/sasson/phamlp/tree/SassNode.php).
Notice: Trying to get property of non-object in SassNode->getLine() (line
208 of
/var/www/drupal-7.10/sites/all/themes/sasson/phamlp/tree/SassNode.php).
Notice: Trying to get property of non-object in SassNode->getSource()
(line 192 of
/var/www/drupal-7.10/sites/all/themes/sasson/phamlp/tree/SassNode.php).

Reply to this email directly or view it on GitHub: https://github.com/richthegeek/phamlp/issues/1#issuecomment-3525402

Regards, Rich

robregonm commented 12 years ago

It would be great to find Compass in PhpSass built-in

b01 commented 12 years ago

I think this is why documentation is crucial, now I have to go figure this out by trial and error. Dang! What a waste of time. So you say that I need to load a callback function into options array, like so: $options = array( 'style' => $style, 'cache' => FALSE, 'syntax' => $syntax, 'debug' => FALSE, 'callbacks' => array( 'warn' => 'cb_warn', 'debug' => 'cb_debug', 'load_path_functions' ), );

But what should be in the definition of the function?

Update: Reading the PHamlP documentation, so I'm starting to get the idea.