Ansible Jinja Filament

From tannerjc wiki
Jump to: navigation, search

debugging jinja

The quickest way to understand what jinja is doing under the covers is to dump the internal code it compiles.

# lib/python2.7/site-packages/jinja2/environment.py
   553     @internalcode
   554     def compile(self, source, name=None, filename=None, raw=False,
   555                 defer_init=False):
               ...
   575         source_hint = None
   576         try:
   577             if isinstance(source, string_types):
   578                 source_hint = source
   579                 source = self._parse(source, name, filename)
   580             source = self._generate(source, name, filename,
   581                                     defer_init=defer_init)
   582             import q; q(source)
   583             if raw:
   584                 return source
   585             if filename is None:
   586                 filename = '<template>'
   587             else:
   588                 filename = encode_filename(filename)
   589             return self._compile(source, filename)
   590         except TemplateSyntaxError:
   591             exc_info = sys.exc_info()
   592         self.handle_exception(exc_info, source_hint=source_hint)