Permalink
Browse files

Handle the case where the engine doesnt match, not only where the ext…

…ension is unset
  • Loading branch information...
1 parent d6df39b commit 87d2a50ae77f18cf00f8a6e58c682e284c2a0f81 @quirkey quirkey committed Jan 12, 2010
Showing with 10 additions and 11 deletions.
  1. +8 −10 lib/sammy.js
  2. +1 −0 test/fixtures/partial.noengine
  3. +1 −1 test/test_sammy_event_context.js
View
@@ -1002,9 +1002,12 @@
if ((engine = path.match(/\.([^\.]+)$/))) { engine = engine[1]; }
// set the engine to the default template engine if no match is found
- if (!engine && this.app.template_engine) {
+ if ((!engine || !$.isFunction(context[engine])) && this.app.template_engine) {
engine = this.app.template_engine;
}
+ if (engine && !$.isFunction(engine) && $.isFunction(context[engine])) {
+ engine = context[engine];
+ }
if (typeof callback == 'undefined') {
if ($.isFunction(data)) {
// callback is in the data position
@@ -1018,15 +1021,10 @@
}
}
data = $.extend({}, data, this);
- wrapped_callback = function(response) {
- if (engine) {
- if ($.isFunction(context[engine])) {
- engine = context[engine];
- }
- if ($.isFunction(engine)) {
- response = engine.apply(context, [response, data]);
- };
- }
+ wrapped_callback = function(response) {
+ if ($.isFunction(engine)) {
+ response = engine.apply(context, [response, data]);
+ };
callback.apply(context, [response]);
context.trigger('changed');
};
@@ -0,0 +1 @@
+NOENGINE
@@ -179,7 +179,7 @@
};
});
this.context = new app.context_prototype(app);
- this.context.partial('fixtures/partial');
+ this.context.partial('fixtures/partial.noengine');
soon(function () {
equals(app.$element().text(), '!!!NOENGINE!!!');
});

0 comments on commit 87d2a50

Please sign in to comment.