-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow "jsonify" to pretty print JSON #5040
Comments
I'm tempted to change the existing one to use I assume we could also add a second optional argument for indentation:
|
Hey guys! I'd love to land this new feature if that's ok 😬 |
@seanprashad I had to reopen this. I suggest we add an optional second argument so both of the below will work: {{ (slice "A" "B" "C") | jsonify }}
{{ (slice "A" "B" "C") | jsonify " " }} |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Also looking for this feature, as we're trying to use the |
@bep has suggested a different approach to what's been discussed here. His comment:
@bep means this:
I agree about future options, but I think the main two use cases were covered in the previous discussions. However, we can support all three cases:
We can easily tell if the argument is a map and handle that case for advanced usages. However, I'd suggest we hold off on the complexity until there's a need for it. Thoughts? |
@moorereason you are mostly right ... but this:
while it works, it's more complex from a maintenance and documentation perspective than this:
In isolation, it may not be much, but it adds up when you look at it on scale. Our dict support is currently a little limited (I hope we can get newline support one day ...), but it does allow you read it in from params etc., so in general it works OK.@ |
+1 for this, it would help in a few places we are displaying json to a user. |
any updates on the open PR for this feature: #7082 ? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
"jsonify" currently uses json.Marshal which emits compact JSON.
We'd like to have the JSON output pretty printed (we're using Hugo for API documentation), so we need some function in Hugo that exposes json.MarshalIndent.
The text was updated successfully, but these errors were encountered: