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

Inline nested jQuery template — {{tmpl}} #132

Closed
abernier opened this issue Aug 13, 2011 · 1 comment
Closed

Inline nested jQuery template — {{tmpl}} #132

abernier opened this issue Aug 13, 2011 · 1 comment

Comments

@abernier
Copy link

Hi,

$.tmpl('<div>Hello <ul>{{tmpl(persons) "<li>${name}</li>"}}</ul></div>', {persons: [
    {name: 'Tom'},
    {name: 'Fred'}
]}).appendTo('body');

throws a SyntaxError

Whereas:

$.tmpl('<div>Hello <ul>{{tmpl(persons) "<li>$"+"{name}</li>"}}</ul></div>', {persons: [
    {name: 'Tom'},
    {name: 'Fred'}
]}).appendTo('body');

works...

Seems jQuery template get confused about parsing the {{tmpl string.

Can it be considered as a bug?

Thank you.

@BorisMoore
Copy link
Owner

You can't nest tags, so you can't do {{foo ...{{blah }} }}, nor can you do {{foo ... ${x} ..}}. It is more a limitation of the parser than a bug. You can do tricks like "$" + "{" to get around that limitation, as you did above. To support that would be too expensive in extra parsing code...

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