ericclemmons / grunt-angular-templates

Grunt build task to concatenate & pre-load your AngularJS templates
MIT License
710 stars 107 forks source link

Basically, the Path module's join assumes you're only working with paths... #57

Closed OlenDavis closed 10 years ago

OlenDavis commented 11 years ago

..., and as url's are not merely paths when they specify a scheme (https://, http://, etc), this normalization breaks some builds. Allows developers to specify strings that incorporate two forward slashes intentionally as part of the scheme of their template urls (for instance, for hosting those files from a CDN when not pre-cached - and note that the Path module's normalization doesn't take this case into account) by checking whether the involved parts of the url include "://" and if so, simply concatenating them, and using Path's join (which normalizes the resulting url) otherwise.

ericclemmons commented 11 years ago

Someone else brought this up too, and just recommended I use url. Thoughts?

OlenDavis commented 11 years ago

How about prefix + url.parse( url )? That way, you enforce the implication that the url is a url, while treating the prefix very simply as a prefix? And any developer that was depending on the nearly undetermined previous behavior will simply be coerced into clarifying their own internal logic.

OlenDavis commented 11 years ago

Sorry; that'd be prefix + url.format( url.parse( urlString ) ) where urlString is the result of the url option string/function.

OlenDavis commented 11 years ago

How's it look Eric?

ericclemmons commented 11 years ago

@OlenDavis Trying to resolve the tests now.

Can you do me a favor & post how you're using this exactly? I'm assuming you have a prefix of http://cdn.mysite.com/assets which is then joined with app/templates/home.html or similar, right?

OlenDavis commented 11 years ago

Like so:

    ngtemplates:
        ngApp:
            cwd    : '<%= pkg.buildDir %>/<%= pkg.builtDir %>/template'
            src    : '**/*.html'
            dest   : builtTemplatesJs

            options:
                module : pkg.ngApp
                url    : ( url ) -> "#{ staticFilePath }template/#{ url }#{ preprocessContext.APPLICATION_CONFIG_staticFileSuffix }"
                htmlmin:
                    collapseBooleanAttributes: no
                    collapseWhitespace       : yes
                    removeAttributeQuotes    : yes
                    removeComments           : yes
                    removeEmptyAttributes    : yes
                    removeRedundantAttributes: yes
ericclemmons commented 10 years ago

Let me know how v0.4.9 works out for ya!

OlenDavis commented 10 years ago

Will do! And thank you kindly!