micromustache icon indicating copy to clipboard operation
micromustache copied to clipboard

Add an option so that strinfigy to JSON.stringify objects

Open alexewerlof opened this issue 5 years ago • 1 comments

Current behavior

If the value is an object or array, [object Object] will be put into the template. This might not be very helpful for debugging (and sometimes this is exactly what you would want, which forces you to write a transformation).

Expected behavior

Add an option like stringifyObjectValues or equivalent in the stringify options and let it put a nicer presentation of objects in the output.

Out of scope

One may want to give special treatment to arrays or set the indentation as well but I'm not aware of any strong use case so let's not add that now.

alexewerlof avatar Aug 17 '20 09:08 alexewerlof

I haven't seen something like that. This is how Mucromustache used to work before but it changed to improve performance.

As a user, it's easy to add that behavior by passing a function to renderFn that stringifies the target object.

On Tue, Jul 27, 2021, 06:40 Shawn Mclean @.***> wrote:

@userpixel https://github.com/userpixel have you found any template library that will stringify your object like this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/userpixel/micromustache/issues/86#issuecomment-887202992, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGMBJW4F4AOXMG27SMSMQDTZY2CDANCNFSM4QBONK3A .

alexewerlof avatar Jul 27 '21 04:07 alexewerlof