JulienCabanes / requirejs-tpl

RequireJS Template Plugin
207 stars 43 forks source link

Alternative to with(obj||{}) #14

Open sekoyo opened 10 years ago

sekoyo commented 10 years ago

Hi,

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with "Using with is not recommended, and is forbidden in ECMAScript 5 strict mode."

I was wondering if there is a way to avoid using with as my closure compiler makes 270 verbose warnings about it and it fails in strict mode. Also the lookups needed make the execution slower.

Is there any 'automagic' way of appending the context variable to the references in the template or do you think the only way around this is to manually append a 'special' variable like ctx when referencing variables from the view in the template?

Thanks