Browse Source

mustache compat: Don't barf on unknown variables.

tags/0.2
Jan Lehnardt 16 years ago
parent
commit
0bb4776def
3 changed files with 4 additions and 3 deletions
  1. +1
    -1
      examples/error_not_found.txt
  2. +2
    -1
      mustache.js
  3. +1
    -1
      test/mustache_spec.rb

+ 1
- 1
examples/error_not_found.txt View File

@@ -1 +1 @@
ERROR: 'foo' not found in context

+ 2
- 1
mustache.js View File

@@ -158,7 +158,8 @@ var Mustache = function() {
if(context[name] !== undefined) {
return context[name];
}
throw({message: "'" + name + "' not found in context"});
// silently ignore unkown variables
return "";
},

// Utility methods


+ 1
- 1
test/mustache_spec.rb View File

@@ -37,7 +37,7 @@ describe "mustache" do
print('ERROR: ' + e.message);
}
JS
run_js(js).should == "ERROR: 'x' not found in context\n"
run_js(js).should == "\n"
end
non_partials.each do |testname|


Loading…
Cancel
Save