     node.attrBindings = token.attrBindings
     node.localeBindings = token.localeBindings
     node.actions = token.actions
+    @parseCustomTag node, parent
     @createNewScope node, parent
-    @parseCustomTag node, parent
     node
 
   createTextNode: (token) ->

      n = parent.context.if
      node.localeBindings.condition = "!(#{n.localeBindings.condition})"
      parent.context.if = null
    else if node.type == T_TAG_OPEN
      throw new Error 'Parse error'



Leaf.Template.customTags['if'] =
  reset: (node, parent) ->
    if node.type == T_TAG_OPEN
      if node.name != 'elseif' && node.name != 'else'
        parent.context.if = null
    else if node.type == T_TAG_CLOSE
      if node.name != 'if' && node.name != 'elseif' && node.name != 'else'
        parent.context.if = null
    else
      parent.context.if = null
