twigkit / tempo

Tempo is an easy, intuitive JavaScript rendering engine that enables you to craft data templates in pure HTML.
http://tempojs.com/
Apache License 2.0
708 stars 73 forks source link

Doesn't work with PrototypeJS :( #18

Closed jamsi closed 13 years ago

jamsi commented 13 years ago

Adding the prototype JS library to the twitter example produces the following error;

Uncaught TypeError: Object function each(iterator, context) { var index = 0; try { this._each(function(value) { iterator.call(context, value, index++); }); } catch (e) { if (e != $break) throw e; } return this; } has no method 'handler'

mrolafsson commented 13 years ago

Did you remove the jQuery references and swap out with Prototype code?

willcannings commented 13 years ago

The issue is around line 285 in the un-minified code. Change the tags loop to something like:

for(var p = 0, c = renderer.tags.length; p < c; p++)

rather than

for(var p in renderer.tags)

Which will fail in prototype because it adds properties to arrays.

mrolafsson commented 13 years ago

Thanks Will, yeah don't know why this wasn't a proper array iteration!! Can you guys see if this fixes your issue: https://github.com/twigkit/tempo/raw/master/tempo.js

Thanks for your help!!!

willcannings commented 13 years ago

Sure does, thanks!

jamsi commented 13 years ago

Yippee. Thanks William.