class JsTemplates(BaseEngine): def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super(JsTemplates, self).__init__(params) self.engine = JsEngine(self.dirs, self.app_dirs, **options) def get_template(self, template_name, dirs=_dirs_undefined): return JsTemplate(self.engine.get_template(template_name))
def test_get_template(self): engine = JsEngine(dirs=[settings.TEMPLATE_DIR]) template = engine.get_template('test-component.js') self.assertIsNotNone(template)
def test_get_template_including_appdirs(self): engine = JsEngine(dirs=[settings.TEMPLATE_DIR], app_dirs=True) template = engine.get_template('test-component.js') self.assertIsNotNone(template)
def test_load_missing_template(self): engine = JsEngine(dirs=[settings.TEMPLATE_DIR]) loader = JsLoader(engine) with self.assertRaises(TemplateDoesNotExist): loader.load_template_source('foo.js')
def test_empty_template_dir_config(self): engine = JsEngine() loader = JsLoader(engine) with self.assertRaises(TemplateDoesNotExist): loader.load_template_source('foo.js')
def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super(JsTemplates, self).__init__(params) self.engine = JsEngine(self.dirs, self.app_dirs, **options)