def _media(self): js = ["js/bootstrap-datetimepicker.js"] language = self.options.get('language', 'en') if language != 'en': js.append("js/locales/bootstrap-datetimepicker.%s.js" % language) options_list = [] for key, value in iter(self.options.items()): options_list.append("%s: %s" % (key, quote(key, value))) js_options = ",\n".join(options_list) js.append(emb.JS(SCRIPT_TEMPLATE[self.bootstrap_version] % dict( id=self.id, options=js_options ))) return widgets.Media( css={ 'all': ('css/datetimepicker.css',) }, js=js )
def _media(self): return Media( css={'all': (emb.CSS('.mywidget { display: none; }'), )}, js=(emb.JS('init_mywidget();'), ))
class Media: css = {'all': (emb.CSS('.mywidget { display: none; }'), )} js = (emb.JS('init_mywidget();'), )
def test_js(self): ## JS rendering js = emb.JS('init_mywidget();') self.assertHTMLEqual( js.render(), '<script type="text/javascript">init_mywidget();</script>')