Converted templates to javascript