flatiron / plates

Light-weight, logic-less, DSL-free, templates for all javascript environments!
MIT License
831 stars 69 forks source link

Problem with function compileMappings, and how i (might have) fixed it. #98

Open LeytonC opened 11 years ago

LeytonC commented 11 years ago

Hello, i have just had an issue with using plates on my Mac OSX version of node (v0.8.9). I am not sure if this would be an issue for everyone, but cannot see a problem like this already issued, but i thought i would mention it.

Every time i ran my node program (simple webserver), loaded a html file and .bind it with a map and data it would work perfectly. 2nd time i loaded it, with a refresh i would get the error

Error: Conflicting mappings for attribute {attribute name} and value {value}

the problem seems to be caused by the slice method called in compileMappings, its missing the second parameter limiting the number of elements returned. I added the extra parameter to limit to a valid mapping so it could be sorted, and i added an shift() after the sort method to remove the map i just processed.

I am not sure if this does fix the problem, as i am not 100% familiar with the code base, and i have not really run it against lots of test cases. I really wanted to see what everyone thought.

Thanks for help and insights in advance (If anything else like code is needed, please just ask.)

Leyton.