benhoIIand / grunt-cache-bust

Cache bust static assets using content hashing
MIT License
265 stars 103 forks source link

Busting angular ng-include templates #163

Closed harshithkashyap closed 8 years ago

harshithkashyap commented 9 years ago

I'm trying to bust the angular partials loaded via ng-include using filters. I've tried the following methods but it doesn't seem to work.

HTML

<div ng-include="'/templates/angular/index.html'"></div>

Gruntfile

cacheBust : {
            options : {
                encoding: 'utf8',
                algorithm: 'md5',
                length: 16,
                rename : false,
                filters : {
                    'div' : function(){
                       return this.attirbs['ng-include'].split("'")[1];
                       //return this.attribs['ng-include'].substr(1,this.attribs['ng-include'].length-2);
                    }
                }
            },
            assets : {
                files :[{
                    expand : true,
                    cwd : 'views/',
                    baseDir : 'client/',
                    src : ['index.ejs']
                }]
            }
        },
nburt commented 8 years ago

@harshithkashyap did you get this working with ng-include templates?

benhoIIand commented 8 years ago

I'd recommend taking a look at the feature/v1.0.0-beta branch. There's a lot of changes in there which you can read in #147

benhoIIand commented 8 years ago

I've added a test case for this myself in feature/v1.0.0-beta branch and is working fine

B00TMan commented 6 years ago

The path get's revved properly but the resulting string isn't a valid ng-include string value. With backlashes in the ng-include="'the\path\to'" the slashes are just escaping characters at runtime, for the case of ng-include it should replace the path with forward slashes, or double back slashes. Any plan to improve this? or suggestions?