help avoiding u" prefixes on template generated output of a dictionary


The goal is to define a dictionary like
 
dict1:
 int1: 5
 str1: "four"
 
and be able to template output the dictionary as a whole (not leaf by leaf) such that the output looks like
 
dict1: {"int1": 5, "srt1": "four"}
 
The actual output prefixes the values on the RHS of the : with a u so it looks like
dict1: {"int1": u"5", "srt1": u"four"}
 

dict1: {“int1”: u"5", “srt1”: u"four"}

Please see the gist for details.
https://gist.github.com/darKoram/3f2fbcc9b3a003546f3c

You should probably use either the to_nice_yaml or to_yaml filters

So that’s just indicating unicode output, I’m curious if it’s causing any specific problems for you?

An example being:

dict1: {{dict1|to_yaml}}

Which produces:

dict1: {_int1: ‘5’, _str1: four}

Oh, nm, you mean templating the directionary. Got it, there is also

{{ dict | to_nice_json }}

as well

Are those underscores before the names of the keys typos?

Thanks matt. to_yaml worked great.

The underscores…
I use hash_behavior = merge and i’ve found that if i define parts of the dict across different files then a statement like

dict1: {{dict1}}

will fail with a “recursive definition detected” message. I was being defensive. In this case, it worked fine removing the underscores from the vars.

k