fabric/fabric — pull request #664 by GigiusB (2012-06-07 22:03:01+00:00)
Title: upload_template with additional loader parameter

Sometimes I find quicker to have a "templates.py" module with some multi-line strings defined to be used as template source instead of a directory.

So far I am "mocking" the jinja2.FileSystemLoader:

def _upload_template( name, dest, **kwargs ):
class JinjaMockLoader(jinja2.DictLoader):
def __init__(self, to_be_discarded):
self.mapping = dict(filter(lambda (k,v): not k.startswith('_'), globals().items() ))
jinja2.FileSystemLoader = JinjaMockLoader
print "Uploading template --> %s" % str(name % env)
upload_template( str(name % env), dest % env, env, use_jinja=True, **kwargs)

IMHO a simple "loader" parameter would do a nicer job...