Comments (6)
Can you try a key other than class
? class
is technically a reserved word in JavaScript.
-Fred
--Science answers questions; philosophy questions answers.
On Tuesday, August 30, 2011 at 4:09 AM, jangingnicht wrote:
hi,
i am having trouble with using the jquery tmpl engine via the $.View call. consider the following call:
$.View("//test/views/test.tmpl",{heads:[{class: "h1", mes: "Ping"}, {class: "h2", mes: "Pong"}]})
if test.tmpl look like this
{{each heads}} <h1>${mes}</h1> {{/each}}
it returns correctly
<h1>Ping</h1> <h1>Pong</h1>
if test tmpl looks like this:
{{each heads}} <h1 class="${class}">${mes}</h1> {{/each}}
undefined is returned whereas i would expect
<h1 class="h1">Ping</h1> <h1 class="h2">Pong</h1>
I just checked out the latest version of jquerymx and tested in Firefox 6.0
Reply to this email directly or view it on GitHub:
#57
from jquerymx.
ups..yeah my mistake...you are right. stupid of me but some kind of error message would be nice if possible at all.
thanks
edit
it looks like it should be working regardless
https://developer.mozilla.org/en/JavaScript/Reference/reserved_words#Reserved_word_usage
not sure though if the issue is in tmpl or jquerymx
will test the same with bare $.tmpl
from jquerymx.
yeah so it turns out jquery.tmpl has hickups with reserved words as IdentifierNames
$.tmpl("{{each heads}}<h1 class='${class}'>${mes}</h1>{{/each}}",{heads:[{class: "h1", mes: "Ping"}, {class: "h2", mes: "Pong"}]})
produces an error, whereass $.tmpl("{{each heads}}<h1 class='${foo}'>${mes}</h1>{{/each}}",{heads:[{foo: "h1", mes: "Ping"}, {foo: "h2", mes: "Pong"}]})
works fine
from jquerymx.
It's not that simple. While it may be technically legal as a key in an object literal, when the template gets compiled, your reference to "class" will be a variable, which is not legal. Additionally, your mileage may vary from browser to browser. Best to just avoid them.
from jquerymx.
yeah you are right...best avoid it.
Apparently it is possible though if ${$data["class"]}
is used...
http://api.jquery.com/jquery.tmpl/#comment-148052151
from jquerymx.
Yes because in this case "class" is just a string, not an identifier.
--Science answers questions; philosophy questions answers.
On Tuesday, August 30, 2011 at 10:01 AM, jangingnicht wrote:
yeah you are right...best avoid it.
Apparently it is possible though if${$data["class"]}
is used...
http://api.jquery.com/jquery.tmpl/#comment-148052151Reply to this email directly or view it on GitHub:
#57 (comment)
from jquerymx.
Related Issues (20)
- formParams() can now only be called on <form> element. formParams() called on other than <form> element returns undefined HOT 2
- Case sensitive file system creates problem HOT 2
- View is never rejected when template is not found HOT 1
- jquery tmpl noConflict
- Cookie: jQuery.evalJSON and jQuery.toJSON HOT 2
- Docs Typo: $.route.attr vs $.route.attrs
- Templated Event Listeners string replacement problem HOT 2
- Fixture does not return correct datatype when error is thrown
- $.Model.delete URL cannot be templated beyond {id} HOT 2
- $.fn.val.call([el]) breaks other jQuery plugins
- $.fixture.make always filters out any fixtures when 'parentId'-like param is present
- $.fn.model(s) ignores type parameter.
- JQueryMX breaks when JQuery is in no-conflicts mode HOT 1
- Default fixture path is hardcoded
- $.fixture templated values not being included in callback data
- jQueryMX breaks when jQuery is in not in global scope HOT 1
- Subclasses of $.Observe are not applied to attribute values HOT 2
- Documentation bug in Controller tutorial
- Bug in remove() from $.Model.List class
- Change <% %> delimeters
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquerymx.