refactored to remove jquery dependency, added lodash for templates