               if parentTokenIdx >=0 then tokenStack[parentTokenIdx].termsThisTagIdx = idxOfToken
               idxOfToken++
 
+            if token is TEMPLATE_END then @templateDepth--
+            
           # case, default statement of switch
           when SWITCH_CASE, SWITCH_DEFAULT
             tokenOnThisLine = true

    indent =  0
    isFirstTagOfBlock = true
    @JSXREGEXP.lastIndex = 0

    for row in [range.start.row..range.end.row]
      isFirstTokenOfLine = true

          # Javascript brace Start { or switch brace start { or paren ( or back-tick `start
          when BRACE_OPEN, SWITCH_BRACE_OPEN, PAREN_OPEN, TEMPLATE_START
            tokenOnThisLine = true
            if token is TEMPLATE_START then @templateDepth++
            if isFirstTokenOfLine
              stackOfTokensStillOpen.push parentTokenIdx = stackOfTokensStillOpen.pop()
              if isFirstTagOfBlock and
