Commits

Rune Halvorsen committed d0c965b

Added test for leaving interpolation marker alone if not matching attr. Made test pass in js and cs implementation

Comments (0)

Files changed (3)

 _strip = (str) -> str.replace /^\s+|\s+$/g, ""
 
 _interpolate = (subject, env) ->
-    subject.replace /{(.+?)}/g, (str, m1) -> _getProperty(m1, env)
+    subject.replace /{(.+?)}/g, (str, m1) -> _getProperty(m1, env) ? str
 
 _getProperty = (propdesc, env) ->
     propchain = propdesc.split(/\.|\[(.*?)\]/).filter((e) -> e)
     }
 
     function _interpolate(subject, env) {
-        return subject.replace(/{(.+?)}/g, function(str, m1) {return _getProperty(m1, env)});
+        return subject.replace(/{(.+?)}/g, function(str, m1) {return _getProperty(m1, env) || str});
     }
 
     function _getProperty(propdesc, env) {

test/linenoise-test.js

 
         var ele = makeNode('a[data-blergh={foo}]', data);
         assert.equals(ele.getAttribute("data-blergh"), "bar");
+
+        var html = makeMarkup('"{blergh}"', data);
+        assert.equals(html, "{blergh}");
     },
 
     "special chars in strings": function() {