mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
allow unicode (utf8) characters in jinja templates
This commit is contained in:
parent
ee34c0c154
commit
39a92f9cd6
2 changed files with 8 additions and 4 deletions
|
@ -21,6 +21,7 @@ import sys
|
|||
import os
|
||||
import shlex
|
||||
import re
|
||||
import codecs
|
||||
import jinja2
|
||||
import yaml
|
||||
import optparse
|
||||
|
@ -233,7 +234,7 @@ def varReplace(raw, vars):
|
|||
def template(text, vars, setup_cache, no_engine=False):
|
||||
''' run a text buffer through the templating engine '''
|
||||
vars = vars.copy()
|
||||
text = varReplace(str(text), vars)
|
||||
text = varReplace(unicode(text), vars)
|
||||
vars['hostvars'] = setup_cache
|
||||
if no_engine:
|
||||
# used when processing include: directives so that Jinja is evaluated
|
||||
|
@ -248,7 +249,7 @@ def double_template(text, vars, setup_cache):
|
|||
|
||||
def template_from_file(path, vars, setup_cache, no_engine=False):
|
||||
''' run a file through the templating engine '''
|
||||
data = file(path).read()
|
||||
data = codecs.open(path, encoding="utf8").read()
|
||||
return template(data, vars, setup_cache, no_engine=no_engine)
|
||||
|
||||
def parse_yaml(data):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue