tactivos / grunt-htmlrefs

Replaces (or removes) references to non-optimized scripts or stylesheets on HTML files
27 stars 14 forks source link

Support Grunt 0.4 #5

Closed krampstudio closed 11 years ago

krampstudio commented 11 years ago

Hi, for my personal needs I've update your task to run on Grunt 0.4

johnnyhalife commented 11 years ago

How's the backward compatibility for this?

On Thu, Feb 14, 2013 at 3:37 AM, Bertrand CHEVRIER <notifications@github.com

wrote:

Hi, for my personal needs I've update your task to run on Grunt 0.4

You can merge this Pull Request by running

git pull https://github.com/krampstudio/grunt-htmlrefs master

Or view, comment on, or merge it at:

https://github.com/tactivos/grunt-htmlrefs/pull/5 Commit Summary

  • start to migrate task to grunt 0.4 way
  • Update task to ran with Grunt 0.4
  • Upgrade internal grunt to 0.4

File Changes

  • R Gruntfile.jshttps://github.com/tactivos/grunt-htmlrefs/pull/5/files#diff-0(2)
  • M package.jsonhttps://github.com/tactivos/grunt-htmlrefs/pull/5/files#diff-1(6)
  • M tasks/grunt-htmlrefs.jshttps://github.com/tactivos/grunt-htmlrefs/pull/5/files#diff-2(66)

Patch Links:

krampstudio commented 11 years ago

This isn't backward compatible to grunt 0.3. Usually the plugin authors maintain a version for 0.4 in another branch and publish it under a new version number, ie. 0.2.x for grunt 0.3 and 0.3.x for grunt 0.4. Up to you to decide if you want a backward compatible version of your plugin: it would be possible by checking each API calls: var _ = grunt.utils ? grunt.utils._ : grunt.util._ and so on, according to the Upgrade guide

alexhanh commented 11 years ago

Seems like includes are broken, ie.

    htmlrefs: {
      dist: {
        src: './app/index.html',
        dest: './dist/',
        includes: {
          airbrake: './app/views/airbrake.html'
        }
      }
    }

inside registerMultiTask we get

var params = this.options();
var includes = (params.includes || {});
console.log(includes) => { }

The reason probably being this.options() returns an empty hash {}.

I'm using grunt 0.4.0rc8, could that be the reason?

krampstudio commented 11 years ago

No it broks because because the way grunt 0.4 manages options, this is an error... I'll update the PR

tanem commented 11 years ago

Any word on incorporating the fix by @krampstudio? Seems to work fine for me.

johnnyhalife commented 11 years ago

Merged and published, hey @krampstudio would you mind adding the standard stuff on the README (like contrib and all), I'll really appreciate your help. Anyway I'm publishing this version!

krampstudio commented 11 years ago

Sure, I'll do it as soon as I have some availability