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

Option to enable/disable tmplItem() support #80

Open yangjh opened 13 years ago

yangjh commented 13 years ago

The tmplItem() method can be quite useful, we can use associate the elements rendered by a template with the data used to create them, however, it also create lots of cache object, or data object in jQuery.cache. If I want to create a table of 1 million rows , and I want the data used to render them to be garbage collected asap. But this is not supported in the current implementation, because the tmplItem() needs the data. So the data cannot be garbage collected. If I don't need the feature of tmplItem(), I just want show the content, it would be nice that I can disable this association explicitly.

BorisMoore commented 13 years ago

Yes, completely agree. This feature is planned, probably with Beta2,

btipling commented 13 years ago

Agreed. I want to show HTML in a textarea without the _tmplitem garbage being added.

btipling commented 13 years ago

Oh nevermind. saw #42.

mAu888 commented 13 years ago

+1, I'm having trouble because of this right now. I'm developing a one page app and my jQuery object keeps on growing because of all those cached tmplItems. Would be a very nice (and handy) feature!

yangjh commented 13 years ago

If you don't need the tmplItem, maybe you should try another template lib jsRender, but you can cleanup these object manually, they are stored in the dataobject of each root of the rendered instance. On Aug 19, 2011 7:42 AM, "mAu888" < reply@reply.github.com> wrote:

+1, I'm having trouble because of this right now. I'm developing a one page app and my jQuery object keeps on growing because of all those cached tmplItems. Would be a very nice (and handy) feature!

Reply to this email directly or view it on GitHub: https://github.com/jquery/jquery-tmpl/issues/80#issuecomment-1850209

mAu888 commented 13 years ago

After some debugging and profiling I figured, that all those tmplItems where created by using the {{html}} tag. Maybe I'm wrong, but for now I switched the template engine and my memory leak went away.

Anybody may have a look into the {{html}} tag and check if it's leaking?

rdworth commented 13 years ago

Thanks for taking the time to submit this issue. Just wanted to let you know this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.

BorisMoore commented 13 years ago

The ongoing work on JsViews and JsRender separates out the tmpItem aspect into JsViews. Just use JsRender if you want optimized rendering without data context or linking. Take a look at this post for more context.