Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nowhere to put template functions #39

Closed
voidfiles opened this issue Jan 4, 2011 · 2 comments
Closed

Nowhere to put template functions #39

voidfiles opened this issue Jan 4, 2011 · 2 comments

Comments

@voidfiles
Copy link

This might be the wrong place, but right now I don't see an easy way to add functions that can be used inside a template.

Is the current recommendation to just add a set of functions accessible in global scope?

@BorisMoore
Copy link
Owner

You can add globals. Alternatively you can pass functions in with options (could be anonymous functions or functions defined within a closure) and then access them via the template item.

I added a new sample, to document this approach: https://github.com/jquery/jquery-tmpl/blob/master/demos/movies/PagesCore/moviesNoGlobals.html:
$( "#bookingEditTmpl" ).tmpl( booking, { formatDate: formatDate } )
${$item.formatDate()}.

See latest commit: f9b00c8

@voidfiles
Copy link
Author

Cool, thanks.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants