Skip to content

Commit

Permalink
Added skiproot feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Tauren Mills committed Aug 12, 2011
1 parent ba9f1db commit dbfecdb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/namespace.coffee
Expand Up @@ -25,6 +25,8 @@ class Namespacer
if settings.templates? then @templates = settings.templates
else callback('Error: \'templates\' is not configured')

if settings.skiproot? then @skiproot = settings.skiproot

if @groupNamespace? and @templates?
@callback = callback
@namespaces = []
Expand Down Expand Up @@ -98,15 +100,17 @@ class Namespacer
self = @

next = ->
self.result[0] = 'var ' + self.result[0]
if not self.skiproot
self.result[0] = 'var ' + self.result[0]
callback(null)

# Get the maximum index for group namespaces in the namespaces array
groupNamespaceLength = (@groupNamespace).split('.').length

# Appends the group namespace declarations
for g in [0...groupNamespaceLength]
self.result.push "#{@namespaces[g]} = #{@namespaces[g]} || {};"
if g > 0 or not @skiproot
self.result.push "#{@namespaces[g]} = #{@namespaces[g]} || {};"

if groupNamespaceLength is @namespaces.length
next()
Expand Down

0 comments on commit dbfecdb

Please sign in to comment.