Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
casset - an alternative asset class which supports minifying scripts, cleaner syntax
  • Whoa, Casset has a community which replies to problems for me. I'm genuinely surprised and impressed. For reference, Daniel15's issue was cross-posted to github at https://github.com/canton7/fuelphp-casset/issues/22 -- we'll resolve the problem there, rather than here.
  • Why can you no longer dynamically add paths? The method is still there but you've made it private, why? I liked being able to add paths. I edited your source and made the method public so I could continue to add paths on the fly. Is there a reason you took this functionality out? Regards,
    Jason
  • Not entirely sure why that change crept in. I'm blaming clumsy fingers when I re-wrote that function. Apologies for the hassle. I've released v1.9 which fixes this. Thanks for bringing it to my attention!
  • Peter, I haven't forgotten your suggestion! Just struggling to find the time to implement it. I've started on it, but there's plenty more I want to do along that line before releasing it (list all assets in a group, give the url of the cache file, etc).
    Don't rely on the new function names in develop staying what they are, I'm tempted to make them a bit shorter. nerdsrescueme, I'm still debating whether something like that lies within the scope of Casset. It involves the manipulation of stylesheets, which I'm counting as outside Casset's scope, but on the other hand it *is* streamlining them, which *is* within scope.
    I am going to write a hooks/callbacks system to allow people to manipulate their stylesheets before Casset caches them, so if I don't include your function in the code itself, I'll set up some sort of hooks contrib/ folder and stick it in there.
  • Great, thanks again canton it's a great package. I think you re-wrote a bit of the read me too, because I'm sure that add_path() was mentioned there somewhere. I can't remember though.
  • Welp I'm sold - thanks for the library! I'll be sure to credit you in my humans.txt.
  • This is a great fit for my website. It was very easy to incorporate. As you stated, configuration is sensible. Very straight-forward for typical applications, and comes with good documentation for anything out of the ordinary. I'm not sure how Dan's forked Assetic compares with this. I had a look at those docs and didn't find it to be as strait-forward as yours. I can also appreciate the simplicity of this package. If I could offer just one small suggestion, it would be to make reference to Fuel::add_package('casset'); and the config always_load. I think you'll be getting a lot of recognition for your work. Thanks for sharing your code!
  • Good news! v1.8 is now available. New features:
    - CSS files are no longer sorted, instead keeping the order they were added to the group in.
    - Allow overriding of js_dir, css_dir and img_dir on a per-path basis (see the 'paths' config key).
    - Casset::render() lost its 'min' parameter. Instead, minification can be controlled on a per-group basis from the config file.
    - 'combine' option added. Read the readme ("Minification and combining" ) for details on how to use this with the 'min' option. This addition changes the behaviour of 'min' slighlty, but shouldn't break anything.
    - Assets at remote locations are now supported. There are (necessarily) some gotchas, so please read the readme!
    - The 'enabled' option in the 'groups' config array is now optional, and defaults to true. Please see the readme for a full run-down, and as usual let me know if you have any comments, queries or suggestions!
  • Thanks for the kind words everyone. v1.3 has just been pushed. Along with other improvements, the readme now has a section explaining how Assetic and Casset differ, and the installation instructions tell you how to autoload the package (good catch, Simon, thanks).
  • I'm planning to use your library on my project and wondering how do you manage assets files in different locations for example mulitple theme dirs? /Assets
    ----/themes
    /default
    /js
    /css
    /img
    /admin
    /js
    /css
    /img It would be cool if you can override the asset location in the config file :) .. thanks again for your great contribution.
  • A Huzz wrote on Saturday 11th of June 2011:
    I'm planning to use your library on my project and wondering how do you manage assets files in different locations for example mulitple theme dirs?

    Current it behaves exactly the same as Asset in this respect. You add the paths you want Casset to search through to the 'paths' config variable, and Casset will search through those and grab the first matching asset it finds. So in your instance you'd add "assets/themes/default/" and "assets/themes/admin/" to the paths array. I'm not entirely happy with this approach however (you're taking something that's nicely namespaced, and stripping all of that out -- what happens if you have two files called 'index.js' and want to include the second?). I'm entirely open to suggestions as to the best way to handle this.
  • Antony Male wrote on Saturday 11th of June 2011:
    A Huzz wrote on Saturday 11th of June 2011:
    I'm planning to use your library on my project and wondering how do you manage assets files in different locations for example mulitple theme dirs?

    Current it behaves exactly the same as Asset in this respect. You add the paths you want Casset to search through to the 'paths' config variable, and Casset will search through those and grab the first matching asset it finds. So in your instance you'd add "themes/default/" and "themes/admin/" to the paths array. I'm not entirely happy with this approach however (you're taking something that's nicely namespaced, and stripping all of that out -- what happens if you have two files called 'index.js' and want to include the second?). I'm entirely open to suggestions as to the best way to handle this.

    thanks for your quick response, if you have identical files can you not place them with the same dir structure in the cache dir? so you will have cache/theme1/js/index.js and cache/theme2/index.js.
  • A Huzz wrote on Saturday 11th of June 2011:
    thanks for your quick response, if you have identical files can you not place them with the same dir structure in the cache dir? so you will have cache/theme1/js/index.js and cache/theme2/index.js.

    Currently, no. This is a flaw that the original Asset library shares. Check back on Monday, however, and I'll try and have something written in. Do you think a syntax like
    Casset::js('admin::index.js')
    
    would work? I don't want the user to have to specify the whole path to the file -- including the 'js/' bit -- as Casset is able to work that out.
    Maybe make the paths array associative, so you can specify this (in your config file)
    'paths' => array(
       'admin' => 'assets/themes/admin/'
    ),
    
    And then invoke this path with the syntax used above? What do you think?
  • Antony Male wrote on Saturday 11th of June 2011:
    A Huzz wrote on Saturday 11th of June 2011:
    thanks for your quick response, if you have identical files can you not place them with the same dir structure in the cache dir? so you will have cache/theme1/js/index.js and cache/theme2/index.js.

    Currently, no. This is a flaw that the original Asset library shares. Check back on Monday, however, and I'll try and have something written in. Do you think a syntax like
    Casset::js('admin::index.js')
    
    would work? I don't want the user to have to specify the whole path to the file -- including the 'js/' bit -- as Casset is able to work that out.
    Maybe make the paths array associative, so you can specify this (in your config file)
    'paths' => array(
       'admin' => 'assets/themes/admin/'
    ),
    
    And then invoke this path with the syntax used above? What do you think?

    I think the config file would be much neater option.. you can make the path optional so that by default it will look into the default assets location unless the path is specified.. what do you think? thanks.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion