Reformatting a php.ini file with Sublime Text 3 for use with Ansible

So quite a specific post this...

PHP .env files are of the format

KEY_A=true
KEY_B="This Is Another Value"

To set variables for use with a Jinja2 template they need to be something along the lines of

key_a: true
key_b: ThisIsAnotherValue

In Sublime Text in the replace all (CTRL+H)
Make sure that regex matching is on and not to preserve case.

Find What: (.+)=(.+)
Replace With: \L$1\E: $2

This will replace two groups of one or more characters. The first will be lowercased, the equals replaced with a colon and then the second group in its original case.

Then the original .env file can have the following in the Jinja2 template

KEY_A={{key_a}}
KEY_B={{key_b}}

Comments

Popular posts from this blog

Windows 7 - Cisco VPN Client

Enabling SNMP on an ASUS RT-N66U

Making Microsoft Dataverse OData queries using Postman