Skip to content

Commit

Permalink
feat(option): add angular.templateCache.urlPrefix option
Browse files Browse the repository at this point in the history
  • Loading branch information
jyounce committed Jul 24, 2015
1 parent 7be889a commit db7ca9b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ gulp rapid-build:test:prod
# angular.httpBackend.prod = (boolean) defaults to false = set to true to enable httpBackend for prod build
# angular.httpBackend.dir = (string) defaults to 'mocks' = directory inside your client scripts directory
# angular.templateCache.dev = (boolean) defaults to false = use template cache when running default and dev task
# angular.templateCache.urlPrefix = (string) prefix for template urls
# angular.templateCache.useAbsolutePaths = (boolean) defaults to false = prefix template urls with a '/'
# spa.title = (string) defaults to package.json name or 'Application' = html title tag value
# spa.description = (string) defaults to package.json description = html meta description tag value
Expand Down
1 change: 1 addition & 0 deletions config/config-angular.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = (config, options) ->
# ==============
angular.templateCache = {}
angular.templateCache.dev = options.angular.templateCache.dev or false
angular.templateCache.urlPrefix = options.angular.templateCache.urlPrefix or ''
angular.templateCache.useAbsolutePaths = options.angular.templateCache.useAbsolutePaths or false

# rb bower dependencies
Expand Down
1 change: 1 addition & 0 deletions config/config-options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = (config, options) ->
options.angular.httpBackend.dir = null if not isType.string options.angular.httpBackend.dir
options.angular.templateCache = {} if not isType.object options.angular.templateCache
options.angular.templateCache.dev = null if not isType.boolean options.angular.templateCache.dev
options.angular.templateCache.urlPrefix = null if not isType.string options.angular.templateCache.urlPrefix
options.angular.templateCache.useAbsolutePaths = null if not isType.boolean options.angular.templateCache.useAbsolutePaths

spaOptions = ->
Expand Down
8 changes: 7 additions & 1 deletion tasks/minify/template-cache.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ module.exports = (gulp, config, watchFile={}) ->
return 'rb' if base.indexOf(config[loc].rb.client[type].dir) isnt -1
'app'

getRoot = ->
useAbsolutePaths = config.angular.templateCache.useAbsolutePaths
prefix = config.angular.templateCache.urlPrefix
prefix = "/#{prefix}" if useAbsolutePaths and prefix[0] isnt '/'
prefix

# streams
# =======
addToDistPath = -> # add 'views/' for app and 'rapid-build/views/' for rb
Expand All @@ -43,7 +49,7 @@ module.exports = (gulp, config, watchFile={}) ->
minify = isProd and config.minify.html.views
minOpts = config.minify.html.options
opts = {}
opts.root = '/' if config.angular.templateCache.useAbsolutePaths
opts.root = getRoot()
opts.module = config.angular.moduleName
gulp.src src
.pipe addToDistPath()
Expand Down

0 comments on commit db7ca9b

Please sign in to comment.