wickman / pystachio

type-checked dictionary templating library for python
MIT License
91 stars 22 forks source link

Unwrap Choice types when stringifying so they can be used in staches #25

Closed timpalpant closed 8 years ago

timpalpant commented 8 years ago

This change defines __str__ and __unicode__ on the Choice type such that it returns the stringified result of the underlying value.

Previously, it was difficult to use a Choice type in a stache expression, since the result would always be stringified as a Choice struct, even if the underlying value were a basic type.

For example, given the following Choice type: C = Choice([Integer, String])

One might want to use the value in a stache template, since both Integer and String are basic types. Previously, this would result in a stache substitution like Choice_Integer_String('hello'). With this change, it will result in a stache substitution of just the underlying value hello.

jsirois commented 8 years ago

@timpalpant this is now released as 0.8.2.

timpalpant commented 8 years ago

Thanks John!