Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
804056a5
Commit
804056a5
authored
Apr 10, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Jinja2 strict undefined in string templating to allow the default filter to be used.
parent
998230a8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
9 deletions
+2
-9
lib/ansible/utils/template.py
+2
-9
No files found.
lib/ansible/utils/template.py
View file @
804056a5
...
...
@@ -19,7 +19,7 @@ import os
import
re
import
codecs
import
jinja2
import
jinja2.meta
as
jinja2_meta
from
jinja2.runtime
import
StrictUndefined
import
yaml
import
json
from
ansible
import
errors
...
...
@@ -410,17 +410,10 @@ def template_from_string(basedir, data, vars):
try
:
if
type
(
data
)
==
str
:
data
=
unicode
(
data
,
'utf-8'
)
environment
=
jinja2
.
Environment
(
trim_blocks
=
True
)
environment
=
jinja2
.
Environment
(
trim_blocks
=
True
,
undefined
=
StrictUndefined
)
environment
.
filters
.
update
(
_get_filter_plugins
())
environment
.
template_class
=
J2Template
# perhaps a nicer way to do this
ast
=
environment
.
parse
(
data
)
undeclared
=
jinja2_meta
.
find_undeclared_variables
(
ast
)
for
x
in
undeclared
:
if
x
not
in
vars
:
return
data
# TODO: may need some way of using lookup plugins here seeing we aren't calling
# the legacy engine, lookup() as a function, perhaps?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment