1. Rune Halvorsen
  2. linenoise

Commits

Rune Halvorsen  committed 807e479

Added property resolution stuff to CS version as well

  • Participants
  • Parent commits 4f64db5
  • Branches default

Comments (0)

Files changed (1)

File linenoise.coffee

View file
 _strip = (str) -> str.replace /^\s+|\s+$/g, ""
 
 _interpolate = (subject, env) ->
-    subject.replace /{(.+?)}/g, (str, m1) -> env[m1] ?= str
+    subject.replace /{(.+?)}/g, (str, m1) -> _getProperty(m1, env)
+
+_getProperty = (propdesc, env) ->
+    propchain = propdesc.split(/\.|\[(.*?)\]/).filter((e) -> e)
+    propchain.reduce ((cont, name) -> cont[name]), env
 
 _makeTextNode = (description, env) ->
     document.createTextNode _interpolate (description.slice 1, -1), env