BorisMoore / jquery-tmpl

The original official jQuery Templates plugin. This project was maintained by the jQuery team as an official jQuery plugin. It is no longer in active development, and has been superseded by JsRender.
3.23k stars 1.01k forks source link

$.tmpl returns lots of <TextNode> elements #161

Open marlun78 opened 13 years ago

marlun78 commented 13 years ago

I know the project has been canceled, but it would be nice if someone who knows how could fix this problem.

BorisMoore commented 13 years ago

You would need to post a simple test case to jsfiddle, for someone to help you here. It may be your issue is an error in your code, or template, not in jquery.tmpl....

marlun78 commented 12 years ago

Yeah, sorry about that! It was not a jquery.tmpl problem. Well sort of. The problem had to do with whitespace in the template file. Once I removed that, it worked fine.

PrisonerZERO commented 12 years ago

I am getting the same issue, but I have no white spaces. In the meantime:

This returns a TextNode? $('

${Text}
').tmpl(instance)

...and yes, instance contains a property called 'Text' (e.g. instance.Text )

This returns EMPTY? $("

").tmpl(instance)

This returns EMPTY? $('

').tmpl({})

ChrisMalone commented 12 years ago

First and foremost, each template needs a wrapper.. This is a dummy tag. Any template not contained in a script tag must be wrapped within a dummy tag. (this is probably because the resulting selectors “HTML()” method is used to return desired markup). Additionally, invalid html will cause it to return empty object. For example, putting a td tag inside a div.

Also see http://bugs.jquery.com/ticket/7188