Alex Rivera | Logout

Can I declare local/temp variables within a jQuery template?

Asked 2011-02-28T21:26:54.827
14

Is it possible to declare new variables within the jQuery template syntax? I'm hoping to achieve the equivalent of this (which does not work):

{{var test = "test"}}

<div>
    ${test}
</div>
Edit
Report

1 Answer

23

I know this has already been answered and accepted, but here is another solution:

${( $data.localVariable = 'SOMETHING' ),''}

A jsFiddle example: http://jsfiddle.net/brettwp/PrfZ5/

answered 2011-11-02T22:09:33.797

Your Answer