Giter Club home page Giter Club logo

Comments (7)

RWOverdijk avatar RWOverdijk commented on July 26, 2024

Yes that is possible. Use the name of the collection for the filter. Check
out the wiki :)
On Oct 7, 2012 6:29 AM, "alexshelkov" [email protected] wrote:

Is it possible to apply filters on collection after all assets are glued
together, instead of applying filter to each asset in collection?


Reply to this email directly or view it on GitHubhttps://github.com//issues/46.

from assetmanager.

alexshelkov avatar alexshelkov commented on July 26, 2024

Yes, I am trying to do it:

'resolver_configs' => array(
    'map' => array(
        'twitter-aaa/bootstrap.less' => __DIR__ . '/../assets/twitter/bootstrap.less',
        'twitter-bbb/variables.less' => __DIR__ . '/../assets/twitter/variables.less'
    ),

    'collections' => array(
        'twitter-test/bootstrap.css' => array(
            'twitter-bbb/variables.less',
            'twitter-aaa/bootstrap.less',
        ),
    ),
),

'filters' => array(
    'twitter-test/bootstrap.css' => array(
        array(
            'filter' => 'LessPhp',
        ),
    ),
),

twitter-bbb/variables.less:

@red: red;

.var-test {
  color: @red;
}

twitter-test/bootstrap.css:

@black: black;

.bot-test {
  color: @red;
  background-color: @black;
}

Output:

.var-test {
  color: red;
}

.bot-test {
  color: ;
  background-color: black;
}

It seems that LessPhp filter applied individually on each asset, instead of applying once on glued asset.

from assetmanager.

RWOverdijk avatar RWOverdijk commented on July 26, 2024

I'm not seeing green being defined anywhere. But it looks like you're simply doing it wrong. Variables go first, then the content. You have them mixed. As for twitter bootstrap, I'm working on a module where this IS working. You may take a look at that: SxBootstrap. It's not finished yet, but I think that it's a start for you (still working on it now).

from assetmanager.

alexshelkov avatar alexshelkov commented on July 26, 2024

I update my prev. comment. Pls check it again.

Variables go first, then the content. You have them mixed.

It is not important when variables goes, LESS allow it until they defined before they are used. This code is parsed correctly:

@black: black;

.bot-test {
  color: @red;
  background-color: @black;
}

@test: 5px + 5px;
.tt {
  border: @test;
}

But even if I move all variables to twitter-bbb/variables.less, it is not working.

I think that its because LESS filter applied on twitter-bbb/variables.less after that it applied on twitter-aaa/bootstrap.less, and after that result of filtering is glued together.

from assetmanager.

RWOverdijk avatar RWOverdijk commented on July 26, 2024

Alex, that's not the expected behavior. I'm actually doing the same with my module and it's working just fine. That's why I asked you to check it out. Usually you have an entry file with imports, otherwise they will be parsed the way they are right now. Try creating one file holding the imports (which I recommend doing anyway).

from assetmanager.

alexshelkov avatar alexshelkov commented on July 26, 2024

Alex, that's not the expected behavior. I'm actually doing the same with my module and it's working just fine. That's why I asked you to check it out.

I really check it out. I even add small portion of code in LessphpFilter:

    public function filterLoad(AssetInterface $asset)
    {
        $root = $asset->getSourceRoot();
        $path = $asset->getSourcePath();

        echo "$path\n";

Its output:
variables.less
bootstrap.less

Which confirms that asset filtered individually by Less. If it is normal, I accept it, and try to find other way to solve my problem.

Usually you have an entry file with imports, otherwise they will be parsed the way they are right now. Try creating one file holding the imports (which I recommend doing anyway).

It works, if all vars defined and used in the same asset. So import is working perfectly fine.

from assetmanager.

RWOverdijk avatar RWOverdijk commented on July 26, 2024

It is expected behavior. See for yourself: https://github.com/kriswallsmith/assetic/blob/master/src/Assetic/Asset/AssetCollection.php#L143. AssetManager allows you to apply filters to nested values, where as collections apply filters to each individual element as well, and then puts them together. If you wish to apply filters to groups, your best bet would be to use the imports. Like I said earlier, that's probably better anyway :) I'm considering this issue closed, I hope this helped!

from assetmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.