mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add None check to fill_template...
... as requested by @nsoranzo.
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
"""Entry point for the usage of Cheetah templating within Galaxy."""
|
||||
from Cheetah.Template import Template
|
||||
|
||||
|
||||
def fill_template( template_text, context=None, **kwargs ):
|
||||
"""Fill a cheetah template out for specified context.
|
||||
|
||||
If template_text is None, an exception will be thrown, if context
|
||||
is None (the default) - keyword arguments to this function will be used
|
||||
as the context.
|
||||
"""
|
||||
if template_text is None:
|
||||
raise TypeError("Template text specified as None to fill_template.")
|
||||
if not context:
|
||||
context = kwargs
|
||||
return str( Template( source=template_text, searchList=[context] ) )
|
||||
|
||||
Reference in New Issue
Block a user