#7244 closed bug (invalid)
If/Else template tag: Templating attributes results in "unexpected token: else"
Reported by: | Owned by: | BorisMoore | |
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | templates | Version: | 1.4.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
For an empty object: {},
Templates that Work:
<div id="{{if something}}{{else}}divid{{/if}}"></div> {{if something}}<div>{{else}}<div id="divid">{{/if}}</div>
Template that does not work (when it should):
<div {{if something}}{{else}}id="divid"{{/if}}></div>
Change History (7)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Shouldn't you report this at the following url? http://github.com/jquery/jquery-tmpl/issues
As this seems to be about the jQuery Templates plugin not about jQuery itself
comment:3 Changed 12 years ago by
According to the bug report page:
For jQuery Core or Official jQuery Plugins (i.e. jQuery Templating or Data Linking): This is the right place!
comment:4 Changed 12 years ago by
Owner: | set to BorisMoore |
---|---|
Status: | new → assigned |
@jitter We're currently accepting tickets regarding the officially supported plugins through Trac so this ticket should be fine. Boris (from MS) will likely follow up.
comment:5 Changed 12 years ago by
This is the wrong way to create templates from strings. $('somestring') requires the string to be HTML, but
<div>{{if something}}<div>{{else}}<div id="divid">{{/if}}two</div></div>,
for example, is not HTML. And $('somestring') cannot parse somestring as a template. So in fact 2 does not work either. The correct way to do example three would be:
var tmpl3 = $.template(null, '<div if}}="" something}}{{else}}id="divid" {{="" {{if="">three</div>'); $.tmpl(tmpl3, {}).appendTo("#tmpl3div");
Or simply:
$.tmpl('<div if}}="" something}}{{else}}id="divid" {{="" {{if="">three</div>', {}).appendTo("#tmpl3div");
comment:6 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
comment:7 Changed 12 years ago by
Component: | unfiled → templates |
---|---|
Priority: | undecided → low |
jsFiddle test case: http://jsfiddle.net/87Gxk/5/