Added general toJSON method and edge case for  attribute
Template can be a string referring to a file name and $el can be a string to be parsed by jQuery