Преглед изворни кода

Using e.messages is unhelpful in the console.

Now just throws straight strings.
with-js-extras
Paul J. Davis пре 16 година
родитељ
комит
02ebf69e04
2 измењених фајлова са 6 додато и 6 уклоњено
  1. +3
    -3
      mustache.js
  2. +3
    -3
      test/mustache_spec.rb

+ 3
- 3
mustache.js Прегледај датотеку

@@ -30,10 +30,10 @@ var Mustache = function() {
*/ */
render_partial: function(name, context, partials) { render_partial: function(name, context, partials) {
if(typeof(context[name]) != "object") { if(typeof(context[name]) != "object") {
throw({message: "Context for '" + name + "' is not an object."});
throw("Context for '" + name + "' is not an object.");
} }
if(!partials || !partials[name]) { if(!partials || !partials[name]) {
throw({message: "No template for partial '" + name + "'."});
throw("No template for partial '" + name + "'.");
} }
return this.render(partials[name], context[name], partials); return this.render(partials[name], context[name], partials);
}, },
@@ -169,7 +169,7 @@ var Mustache = function() {
} else { } else {
src = context.toString(); src = context.toString();
} }
throw({message: "'" + name + "' not found in context: " + src});
throw("'" + name + "' not found in context: " + src);
} }
ctx = ctx[p]; ctx = ctx[p];
} }


+ 3
- 3
test/mustache_spec.rb Прегледај датотеку

@@ -34,7 +34,7 @@ describe "mustache" do
try { try {
print(Mustache.to_html("{{#list}}{{x}}{{/list}}", {list: [{}]})); print(Mustache.to_html("{{#list}}{{x}}{{/list}}", {list: [{}]}));
} catch(e) { } catch(e) {
print('ERROR: ' + e.message);
print('ERROR: ' + e);
} }
JS JS
run_js(js).should == "ERROR: 'x' not found in context: {list:[{}]}\n" run_js(js).should == "ERROR: 'x' not found in context: {list:[{}]}\n"
@@ -54,7 +54,7 @@ describe "mustache" do
var result = Mustache.to_html(template, #{testname}); var result = Mustache.to_html(template, #{testname});
print(result); print(result);
} catch(e) { } catch(e) {
print('ERROR: ' + e.message);
print('ERROR: ' + e);
} }
JS JS


@@ -79,7 +79,7 @@ describe "mustache" do
var result = Mustache.to_html(template, partial_context, partials); var result = Mustache.to_html(template, partial_context, partials);
print(result); print(result);
} catch(e) { } catch(e) {
print('ERROR: ' + e.message);
print('ERROR: ' + e);
} }
JS JS


Loading…
Откажи
Сачувај