Skip to content
Permalink
Browse files

feat(option): add angular.templateCache.urlPrefix option

  • Loading branch information
jyounce committed Jul 24, 2015
1 parent 7be889a commit db7ca9bcf56345f40d81b3c93f3beb4c52b11db2
Showing with 10 additions and 1 deletion.
  1. +1 −0 README.md
  2. +1 −0 config/config-angular.coffee
  3. +1 −0 config/config-options.coffee
  4. +7 −1 tasks/minify/template-cache.coffee
@@ -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
@@ -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
@@ -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 = ->
@@ -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
@@ -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()

0 comments on commit db7ca9b

Please sign in to comment.
You can’t perform that action at this time.