Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Explicit binding of functions/methods passed to template engine #69

merged 2 commits into from Aug 16, 2013


None yet
4 participants

robertklep commented Jan 3, 2013

I ran into an issue trying to get the Swig template engine to work with Locomotive: using any of the *Path() functions from within templates failed with a type error: TypeError: Object #<Object> has no method 'urlFor'.

Not quite sure who's at fault, but the reason turns out to be that the *Path() functions weren't bound to the current controller instance (but to the global app object, I think), and thus were running in the wrong context.

This patch explicitly binds all functions passed to the template engine to the current controller, which has solved my problems.

Logically I have the same error with Jade. There's also a topic on StackOverflow http://stackoverflow.com/questions/17507198/routing-helpers-in-jade-views-locomotive-framework .

I tested the patch for the locals and it works. The broken error handling is already fixed.

Jared it would be great to have feedback from you for this bugfix.


drudge commented Aug 11, 2013

@jaredhanson What do you think of this?

@jaredhanson jaredhanson added a commit that referenced this pull request Aug 16, 2013

@jaredhanson jaredhanson Merge pull request #69 from robertklep/master
Explicit binding of functions/methods passed to template engine

@jaredhanson jaredhanson merged commit f459b76 into jaredhanson:master Aug 16, 2013

1 check passed

default The Travis build passed

jaredhanson commented Aug 16, 2013

Merged and published as locomotive v0.3.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment