Python jinja2.DebugUndefined() Examples
The following are 8
code examples of jinja2.DebugUndefined().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
jinja2
, or try the search function
.
Example #1
Source File: jinja2.py From bioforum with MIT License | 6 votes |
def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super().__init__(params) self.context_processors = options.pop('context_processors', []) environment = options.pop('environment', 'jinja2.Environment') environment_cls = import_string(environment) if 'loader' not in options: options['loader'] = jinja2.FileSystemLoader(self.template_dirs) options.setdefault('autoescape', True) options.setdefault('auto_reload', settings.DEBUG) options.setdefault('undefined', jinja2.DebugUndefined if settings.DEBUG else jinja2.Undefined) self.env = environment_cls(**options)
Example #2
Source File: jinja2.py From Hands-On-Application-Development-with-PyCharm with MIT License | 6 votes |
def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super().__init__(params) self.context_processors = options.pop('context_processors', []) environment = options.pop('environment', 'jinja2.Environment') environment_cls = import_string(environment) if 'loader' not in options: options['loader'] = jinja2.FileSystemLoader(self.template_dirs) options.setdefault('autoescape', True) options.setdefault('auto_reload', settings.DEBUG) options.setdefault('undefined', jinja2.DebugUndefined if settings.DEBUG else jinja2.Undefined) self.env = environment_cls(**options)
Example #3
Source File: jinja2.py From python with Apache License 2.0 | 6 votes |
def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super(Jinja2, self).__init__(params) self.context_processors = options.pop('context_processors', []) environment = options.pop('environment', 'jinja2.Environment') environment_cls = import_string(environment) if 'loader' not in options: options['loader'] = jinja2.FileSystemLoader(self.template_dirs) options.setdefault('autoescape', True) options.setdefault('auto_reload', settings.DEBUG) options.setdefault('undefined', jinja2.DebugUndefined if settings.DEBUG else jinja2.Undefined) self.env = environment_cls(**options)
Example #4
Source File: __init__.py From ops-cli with Apache License 2.0 | 6 votes |
def __init__(self, root_dir, ops_config): loader = ChoiceLoader([ FileSystemLoader(root_dir), FileSystemLoader("/") ]) mode = ops_config.get('jinja2.undefined') undefined = Undefined if mode == 'StrictUndefined': undefined = StrictUndefined elif mode == 'DebugUndefined': undefined = DebugUndefined self.env = Environment(loader=loader, undefined=undefined) self.filter_plugin_loader = PluginLoader( 'FilterModule', 'ansible.plugins.filter', ops_config.ansible_filter_plugins.split(':'), 'filter_plugins' ) for filter in self.filter_plugin_loader.all(): self.env.filters.update(filter.filters())
Example #5
Source File: jinja2.py From python2017 with MIT License | 6 votes |
def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super(Jinja2, self).__init__(params) self.context_processors = options.pop('context_processors', []) environment = options.pop('environment', 'jinja2.Environment') environment_cls = import_string(environment) if 'loader' not in options: options['loader'] = jinja2.FileSystemLoader(self.template_dirs) options.setdefault('autoescape', True) options.setdefault('auto_reload', settings.DEBUG) options.setdefault('undefined', jinja2.DebugUndefined if settings.DEBUG else jinja2.Undefined) self.env = environment_cls(**options)
Example #6
Source File: yasha.py From yasha with MIT License | 5 votes |
def load_jinja( path, tests, filters, classes, mode, trim_blocks, lstrip_blocks, keep_trailing_newline): from jinja2.defaults import BLOCK_START_STRING, BLOCK_END_STRING, \ VARIABLE_START_STRING, VARIABLE_END_STRING, \ COMMENT_START_STRING, COMMENT_END_STRING, \ LINE_STATEMENT_PREFIX, LINE_COMMENT_PREFIX, \ NEWLINE_SEQUENCE undefined = { 'pedantic': jinja.StrictUndefined, 'debug': jinja.DebugUndefined, None: jinja.Undefined, } env = jinja.Environment( block_start_string=BLOCK_START_STRING, block_end_string=BLOCK_END_STRING, variable_start_string=VARIABLE_START_STRING, variable_end_string=VARIABLE_END_STRING, comment_start_string=COMMENT_START_STRING, comment_end_string=COMMENT_END_STRING, line_statement_prefix=LINE_STATEMENT_PREFIX, line_comment_prefix=LINE_COMMENT_PREFIX, trim_blocks=trim_blocks, lstrip_blocks=lstrip_blocks, newline_sequence=NEWLINE_SEQUENCE, keep_trailing_newline=keep_trailing_newline, extensions=classes, undefined=undefined[mode], loader=jinja.FileSystemLoader(path) ) env.tests.update(tests) env.filters.update(filters) return env
Example #7
Source File: jinja2.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super(Jinja2, self).__init__(params) environment = options.pop('environment', 'jinja2.Environment') environment_cls = import_string(environment) options.setdefault('autoescape', True) options.setdefault('loader', jinja2.FileSystemLoader(self.template_dirs)) options.setdefault('auto_reload', settings.DEBUG) options.setdefault('undefined', jinja2.DebugUndefined if settings.DEBUG else jinja2.Undefined) self.env = environment_cls(**options)
Example #8
Source File: jinja2.py From openhgsenti with Apache License 2.0 | 5 votes |
def __init__(self, params): params = params.copy() options = params.pop('OPTIONS').copy() super(Jinja2, self).__init__(params) environment = options.pop('environment', 'jinja2.Environment') environment_cls = import_string(environment) options.setdefault('autoescape', True) options.setdefault('loader', jinja2.FileSystemLoader(self.template_dirs)) options.setdefault('auto_reload', settings.DEBUG) options.setdefault('undefined', jinja2.DebugUndefined if settings.DEBUG else jinja2.Undefined) self.env = environment_cls(**options)