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

i can't get the right instance of WPLessCompiler in WPLessPlugin #51

Open
bassjobsen opened this issue Dec 7, 2013 · 7 comments
Open

Comments

@bassjobsen
Copy link

I try to add https://github.com/oyejorge/less.php to compile, see also https://github.com/bassjobsen/wp-lesscss

in my functions.php i define:

if (class_exists('WPLessPlugin'))
{
    $less = WPLessPlugin::getInstance();
    $less->addVariable('myColor', 'purple');
}

with addVariable in WPLessPlugin:

    public function addVariable($name, $value)
    {
        $this->compiler->parse('@'.$name.': '.$value.';');
    }

and

class WPLessCompiler extends Less_Parser
{

}

$this->compiler->parse seems to set Less_Parser->rules but will be reset after every call to addVariable();
Calling $this->parse() inside Less_Parser->getCss() works as expected.
For me it seems addVariable creates a new instance of WPLessCompiler every time and i don't understand why.
Hope you can help.

@oyejorge
Copy link

oyejorge commented Dec 7, 2013

Is there somewhere on github I can see the full code for WPLessCompiler and WPLessPlugin? Everything I've found so far has leafo's lessphp compiler.

@bassjobsen
Copy link
Author

@oyejorge yes, see here https://github.com/bassjobsen/wp-lesscss. It will work to compile a simple LESS file (also Bootstrap's latest version), but i found some problems trying implement setVariables().

NB https://github.com/bassjobsen/wp-less-to-css also use less.php here all works as expected.

@oyejorge
Copy link

oyejorge commented Dec 8, 2013

Sorry, nothing is jumping out at me. You mentioned wp-less-to-css is working as expected using less.php. Does that mean it's working with multiple calls to parse()?

@bassjobsen
Copy link
Author

Okay, thanks for checking!! Yes multiple calls seems not the problem.
Most likely the WPLessPlugin starts new instances where i expect using the started instance.

@thom4parisot
Copy link
Owner

@bassjobsen is it also the behaviour of lessphp#compileFile? Because if that method resets the data you are talking about, the plugin has nothing to do with that.

Otherwise, it is fixable.

@bassjobsen
Copy link
Author

@oncletom good suggestion, i will check that soon! thanks

@thom4parisot
Copy link
Owner

Fine, let us know your findings :-)

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

3 participants