Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document regex_replace Jinja filter #48952

Closed
mbunkus opened this issue Aug 6, 2018 · 4 comments
Closed

document regex_replace Jinja filter #48952

mbunkus opened this issue Aug 6, 2018 · 4 comments
Labels
Bug broken, incorrect, or confusing behavior Documentation Relates to Salt documentation P3 Priority 3 severity-low 4th level, cosemtic problems, work around exists
Milestone

Comments

@mbunkus
Copy link
Contributor

mbunkus commented Aug 6, 2018

Description of Issue/Question

The "Understanding Jinja" section documents and lists regex_match and regex_search but not regex_replace. However, that function is actually present in salt/utils/jinja.py and works just fine.

It should really be documented. I've been Googling for ways to regex-replace in Jinja several times now, seeing as the documentation stated such a function doesn't exist, and only a look under the hood (into jinja.py) revealed that it does exist after all.

Steps to Reproduce Issue

Small test state that shows the function works just fine:

{% set a = '/tmp/hellely' %}
{{ a | regex_replace('l(.)', 'a\\1') }}:
  file.directory

Saving this as testme.sls & executing it (salt-call testme) will create /tmp/healeay as expected.

Versions Report

Salt Version:
           Salt: 2018.3.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.30.1
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.15 (default, Jun 27 2018, 13:05:28)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 17.0.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.3

System Versions:
           dist:
         locale: UTF-8
        machine: x86_64
        release: 4.17.5-1-ARCH
         system: Linux
        version: Not Installed
@garethgreenaway garethgreenaway added Bug broken, incorrect, or confusing behavior Documentation Relates to Salt documentation labels Aug 6, 2018
@garethgreenaway
Copy link
Contributor

@mbunkus Thanks for the report. It looks like the documentation for this function is available in salt/utils/jinja.py so the docstring for the regex_search function would simply need to be copied into salt/doc/topics/jinja/index.rst. We would definitely welcome a pull request with this addition.

@garethgreenaway garethgreenaway added this to the Approved milestone Aug 6, 2018
@garethgreenaway garethgreenaway added severity-low 4th level, cosemtic problems, work around exists severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P2 Priority 2 P3 Priority 3 and removed severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P2 Priority 2 labels Aug 6, 2018
@mbunkus
Copy link
Contributor Author

mbunkus commented Aug 6, 2018

Oh, I wasn't aware that they're not built automatically from the Python files somehow. Sure, I can whip up a PR.

@rallytime
Copy link
Contributor

Thanks @mbunkus!

@mbunkus
Copy link
Contributor Author

mbunkus commented Aug 6, 2018

You're quite welcome.

Ch3LL pushed a commit to Ch3LL/salt that referenced this issue Mar 26, 2019
Akm0d pushed a commit that referenced this issue Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Documentation Relates to Salt documentation P3 Priority 3 severity-low 4th level, cosemtic problems, work around exists
Projects
None yet
Development

No branches or pull requests

3 participants