Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of how to include it without drupal module? #4

Closed
globerunnerseo opened this issue Mar 6, 2012 · 9 comments
Closed

Example of how to include it without drupal module? #4

globerunnerseo opened this issue Mar 6, 2012 · 9 comments

Comments

@globerunnerseo
Copy link

By some could you provide an example of how to include this into a single standalone php file ? I'd like to include your work into a zend project and a handful of things.

@richthegeek
Copy link
Owner

Sure, i'll write one up in the next few hours.

It's pretty simple (although needs documenting) on the config options side but needs some special munging to make additional load paths and custom functions available.

@baptwit
Copy link

baptwit commented Mar 7, 2012

Hi,

I'm new with all those sass and compass things, i'm sorry if i'll say stupid things but i don't really know how sass and compass work.But i can see how sass is looking awesome and i also want to include your work into my future projects.

In other issue you've said that include compass need some custom functions, and here you said it needs some special munging. I'm not sure what munging is, i think that you said it needs some work for making custom functions available.

So my question is : is compass will be available to use with your PHPSass and will it be hard to use or simple as telling to a config file where compass is?

@chrisjlee
Copy link

@baptwit are you referring to this? #1 (comment)

@baptwit
Copy link

baptwit commented Mar 13, 2012

@chrisjlee Yes, and specifically this sentence : "Compass is a little more complicated as it also includes additional functions "
Here there is "It's pretty simple [...] to make additional load paths and custom functions available."

So i was wondering if adding functions is simple, there will be something to show how to include compass to phpsass ;)

@richthegeek
Copy link
Owner

@baptwit @chrisjlee since the comment in #1, the extensions method has been temporarily removed (it was adding complexity in fixing bugs with @import). We will be adding them back in once we have fixed on a way to do it properly.

To add Compass at the moment, you need to feed the list of Compass functions to the SassParser options array. If you look at the slide with the subhead "Custom Functions" in http://livelinknewmedia.com/documents/Making%20Drupal%20Sassy.pdf that should give you the required detail.

The actual code for the functions is available in http://drupalcode.org/project/sassy.git/tree/refs/heads/7.x-2.x:/extensions/compass/functions and the "sassy_compass_sassy_functions" in http://drupalcode.org/project/sassy.git/blob/refs/heads/7.x-2.x:/extensions/compass/sassy_compass.module

@richthegeek
Copy link
Owner

With regards to "A little more complicated", I meant "in relation to other PHamlP forks", not actual complexity... hopefully you can see it's pretty simple to actually do it (just add the functions to the parser options, and add the Compass load dir to the load_path_functions)...

@globerunnerseo
Copy link
Author

Rich:

So in order to create utilize your sass processor as a standalone i need to include it with the constructor and then provide it a path?

@richthegeek
Copy link
Owner

Yes, this code is what I use as a standalone file:

<?php
$file = $_GET['file'];
$path = './phpsass';
$library = $path . '/SassParser.php';

if ($path && file_exists($library)) {

    header('Content-type: text/css');

    try {
        require_once ($library);
        $options = array(
            'style' => 'expanded',
            'cache' => FALSE,
            'syntax' => 'scss',
            'debug' => FALSE,
            'debug_info' => FALSE,
            'functions' => array(
                'rand' => 'rand',
            ),
        );
        // Execute the compiler.
        $parser = new SassParser($options);
        print $parser->toCss($file);
    }
    catch (Exception $e) {
        print "body::before {
          display: block;
          padding: 5px;
          white-space: pre;
          font-family: monospace;
          font-size: 8pt;
          line-height: 17px;
          overflow: hidden;
          content: '" . $e->getMessage() . "';
        }";
    }
}

The path of the $file is automatically added to the parser's load paths, but you can add additional ones by using the load_paths => array() parser option

@tsi
Copy link

tsi commented Sep 6, 2012

the extensions method has been temporarily removed ... We will be adding them back in once we have fixed on a way to do it properly.

Did you ever got to that ? if not, any hint on what was removed and what should be done ? I'd like to help with that. I'm looking to be able to add compass as it was in the original phamlp, without listing all the functions etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants