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

Assets Manager doesn't use result of preceding css filter as the source for the next one #1198

Closed
Lisio opened this issue Sep 4, 2013 · 4 comments

Comments

@Lisio
Copy link

Lisio commented Sep 4, 2013

Using custom scss filter and framework's cssmin filter for one scss file results in a file, that contains both the generated css and minified scss.

ScssFilter.php

class ScssFilter implements Phalcon\Assets\FilterInterface
{
    public function filter($contents)
    {
        $scss = new scssc();
        return $scss->compile($contents);
    }
}

GenericController.php

$this->assets
->collection('css')
->setTargetPath('css/result.css')
->setTargetUri('css/result.css')
->addCss('../app/assets/css/style.scss')
->addFilter(new ScssFilter())
->addFilter(new Phalcon\Assets\Filters\Cssmin());

style.scss

a {
    b {
        color: black;
    }
}

result.css

a b {
  color: black; }
a{b { color: black;}}
@dreamsxin
Copy link
Contributor

Could you please submit a test to reproduce the problem?
I test it ok, If the problem is the class SCSSC?

class TrimFilter implements Phalcon\Assets\FilterInterface
{
    public function filter($contents)
    {
        $contents = str_replace(array("\n", "\r", " "), '', $contents);
        return $contents;
    }
}

$assets = new Phalcon\Assets\Manager();
$css = $assets->collection('css');

$css->setTargetPath('unit-tests/assets/production/1198.css');
$css->setTargetUri('production/1198.css');
$css->addCss('unit-tests/assets/1198.css');
$css->addFilter(new trimFilter());
$css->join(TRUE);
$html = $assets->outputCss('css');

result:

a{b{color:black;}}

@Lisio
Copy link
Author

Lisio commented Sep 14, 2013

You use only one filter. Please try this code:

$css->setTargetPath('unit-tests/assets/production/1198.css');
$css->setTargetUri('production/1198.css');
$css->addCss('unit-tests/assets/1198.css');
$css->addFilter(new trimFilter());
$css->addFilter(new Phalcon\Assets\Filters\Cssmin());
$css->join(TRUE);
$html = $assets->outputCss('css');

@ghost ghost mentioned this issue Sep 15, 2013
phalcon pushed a commit that referenced this issue Sep 17, 2013
@phalcon
Copy link
Collaborator

phalcon commented Sep 25, 2013

This is fixed in 1.3.0, could you give it a try?

@Lisio
Copy link
Author

Lisio commented Sep 26, 2013

Yes, in 1.3.0 it works as expected.

@Lisio Lisio closed this as completed Sep 26, 2013
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

2 participants