On Monday, November 7, 2016 at 3:15:59 PM UTC+1, [email protected] 
wrote:
>
> I would like this escaping to be done automatically, how should I proceed?
>
> I've looked for "xml escaping jinja filter" without any luck.
>

For the record, the solution was to write my own xml-escaping filter plugin.

Which is easy enough:

$ cat filter_plugins/myfilters.py
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import xml.sax.saxutils
class FilterModule(object):
    ''' my jinja2 filters for ansible'''
    def filters(self):
        return {'escape_xml_attr' : xml.sax.saxutils.quoteattr,
                'escape_xml_data' : xml.sax.saxutils.escape}

Then, use it like this

 - { role: jenkinspipelinejob, name: 'feeds', script: "{{ lookup('file', 
'jenkins/jobs/feeds/script.groovy') | escape_xml_data }}" }

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9f44ae3b-c674-4b59-8f7d-cb8aa17d597c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to