jgm/doctemplates

conversion from JSON values - is it possible to force it?

Opened this issue · 1 comments

I have found that I seem to be able to force the conversion of a JSON variable when it is used for interpolation in a template by using xx.c to force conversion to a character string. Without the appended .c the variable is included as a boolean.

The ReadMe file states:

When a Context is derived from an aeson (JSON) Value, the following conversions are done:

    If the value is a number, it will be rendered as an integer if possible, otherwise as a floating-point number.

which hints that my accidental discovery is intentional in the code - but I cannot discover where in the source this is done.

Would it be possible to add a list of the respective codes to the ReadMe file? Thank you!

jgm commented

I'm not clear what you mean. Please give a reproducible example that I can run myself.