示例#1
0
文件: widgets.py 项目: k3njiy/indico
 def __call__(self, field, **kwargs):
     if self.plugin:
         plugin = self.plugin
         if hasattr(plugin, 'name'):
             plugin = plugin.name
         template = '{}:{}'.format(plugin, self.template)
     else:
         template = self.template
     if self.single_kwargs:
         kwargs = {'input_args': kwargs}
     template_module = get_template_module(template, field=field, **dict(self.context, **kwargs))
     javascript = template_module.javascript()
     if '<script' in javascript:
         inject_js(template_module.javascript())
     elif html_commment_re.sub('', javascript).strip():
         raise ValueError("Template did not provide valid javascript")
     return HTMLString(template_module.html())
示例#2
0
文件: widgets.py 项目: wtakase/indico
 def __call__(self, field, **kwargs):
     if self.plugin:
         plugin = self.plugin
         if hasattr(plugin, 'name'):
             plugin = plugin.name
         template = '{}:{}'.format(plugin, self.template)
     else:
         template = self.template
     if self.single_kwargs:
         kwargs = {'input_args': kwargs}
     template_module = get_template_module(template, field=field, **dict(self.context, **kwargs))
     javascript = template_module.javascript()
     if '<script' in javascript:
         inject_js(template_module.javascript())
     elif html_commment_re.sub('', javascript).strip():
         raise ValueError("Template did not provide valid javascript")
     return HTMLString(template_module.html())
示例#3
0
文件: widgets.py 项目: javfg/indico
 def __call__(self, field, **kwargs):
     if self.plugin:
         plugin = self.plugin
         if hasattr(plugin, 'name'):
             plugin = plugin.name
         template = f'{plugin}:{self.template}'
     else:
         template = self.template
     if self.single_kwargs:
         kwargs = {'input_args': kwargs}
     template_module = get_template_module(template,
                                           field=field,
                                           **(self.context | kwargs))
     javascript = template_module.javascript()
     html = template_module.html()
     if self.inline_js:
         html += '\n' + javascript
     elif '<script' in javascript:
         inject_js(template_module.javascript())
     elif html_comment_re.sub('', javascript).strip():
         raise ValueError('Template did not provide valid javascript')
     return Markup(html)