Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix on Parser class pushes in undefined elements

  • Loading branch information...
commit 606497a7480864c18f96c94a7de103fb2f537cb9 1 parent dc36b4f
@fadrizul authored
Showing with 14 additions and 6 deletions.
  1. +14 −6 lib/parser.coffee
View
20 lib/parser.coffee
@@ -7,7 +7,7 @@ Author: Fadrizul H. <fadrizul[at]gmail.com>
x = require "./regexes"
pr = require "../dev/eyes" # Debugging purposes
-# This class create the Parser tree
+# This class create the Token tree
class Parser
constructor: (str, tags) ->
@rawTokens = if str then str.trim().replace(x.Replace, "").split(x.Split) else {} # Rearranges str in to array
@@ -20,7 +20,7 @@ class Parser
# Loop through @rawTokens
for token, i in @rawTokens
# If there are comment delimters {# #} ignore it
- continue if token.length is 0 or x.CmntDelimiter.test(token)
+ continue if x.CmntDelimiter.test(token)
# Relaces empty namespaces with \n
if x.Spaces.test(token)
@@ -78,17 +78,25 @@ class Parser
args : if parts.length then parts else []
compile : @tags[tagname]
+ # Pushes extends tag into stack
+ if tagname is "extends"
+ stack[index].push(token)
+
# If it's the end of the tag, pushes the string
# in between the tags in to stack and reset index to 0
if @tags[tagname].ends
- token.tokens = @rawTokens[i+1]
+ nextIndex = i + 1
+ token[parts] = @rawTokens[nextIndex]
+ @rawTokens.splice(nextIndex, 1)
+
stack[index].push(token)
index++
continue
# If it's only string, pushes it into stack for compiling
- else
- stack[index].push(token)
-
+ else
+ if typeof token isnt "undefined"
+ stack[0].push(token)
+
# return the new Parser tree
return stack[index]
Please sign in to comment.
Something went wrong with that request. Please try again.