Skip to content

Commit

Permalink
Merge pull request #188 from trengrj/master
Browse files Browse the repository at this point in the history
Allow more liberal matching of template names
  • Loading branch information
endor committed Feb 1, 2014
2 parents fb196a1 + 6c045f9 commit 7b44259
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sammy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ $.extend(Sammy.DefaultLocationProxy.prototype , {
if (_isFunction(engine)) { return engine; }
// lookup engine name by path extension
engine = (engine || context.app.template_engine).toString();
if ((engine_match = engine.match(/\.([^\.\?\#]+)$/))) {
if ((engine_match = engine.match(/\.([^\.\?\#]+)(\?|$)/))) {
engine = engine_match[1];
}
// set the engine to the default template engine if no match is found
Expand Down
9 changes: 9 additions & 0 deletions test/event_context_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ describe('EventContext', function() {
});
});

it('runs through template() if Sammy.Template _is_ present _and_ GET parameters appended', function(done) {
app.use(Sammy.Template);
context = new app.context_prototype(app);
context.partial('./fixtures/../fixtures/partial.template?var1=09&var2=abc', {name: 'TEMPLATE!', class_name: 'test_template'}).then(function(data) {
expect(data).to.eql('<div class="test_template">TEMPLATE!</div>');
done();
});
});

it('replaces the default app element if no callback is passed', function(done) {
listenToChanged(app, {
setup: function() {
Expand Down

0 comments on commit 7b44259

Please sign in to comment.