Hi

I'm templating PHP configuration files, but having some issues trying
to make variables work that can be different types.
Take for instance this snippet of config that I'm trying to template:

    /*
     * Cookie domain.
     *
     * Can be used to make the session cookie available to several domains.
     *
     * Example:
     *  'session.cookie.domain' => '.example.org',
     */
    'session.cookie.domain' => null,

The var I have in my ansible defaults is:

session_cookie_domain: null

The line in the template is:

    'session.cookie.domain' => {{ session_cookie_domain }},

If that gets replaced with the var (null) then things are OK.
However, when I use an actual string the PHP file is invalid as there
should be quotes around the value.
The same happens for other variables that can be string or boolean.

If I add quotes to the template then those will also surround
null/booleans, resulting in working PHP code, but with the wrong
outcome:

session_cookie_domain: 'null'



What I'm looking for is a way to have jinja add quotes depending on
the type of var that is being substituted.

Is something like this available?
It would make for a nice filter.

thanks

Dick


-- 
Dick Visser
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwO_3vkQj%2BZUHrDLpv0Yw8zScXup62OcUk1rfyde-7KRXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to