-
-
Notifications
You must be signed in to change notification settings - Fork 187
Add JsonWriterOptions to TemplateOptions and TemplateContext #846
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
Conversation
…Json filter Co-authored-by: sebastienros <[email protected]>
Co-authored-by: sebastienros <[email protected]>
Co-authored-by: sebastienros <[email protected]>
|
@copilot change the behavior of the json filter so it doesn't take an argument. Instead it will use the context option as it is. By default the JsonWriterOptions should not be indented, this might be a breaking change. |
Co-authored-by: sebastienros <[email protected]>
Done in commit a9eb47a. The json filter now uses |
Fluid/TemplateContext.cs
Outdated
| /// <summary> | ||
| /// Gets or sets the <see cref="JsonWriterOptions"/> used by the <c>json</c> filter. | ||
| /// </summary> | ||
| public JsonWriterOptions JsonWriterOptions { get; set; } = new JsonWriterOptions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot The initialization is unnecessary because the value is set in the constructor from the TemplateOptions
Adds configurable
JsonWriterOptionstoTemplateOptionsandTemplateContext, allowing fine-grained control over JSON serialization (indentation, encoding, depth limits) in thejsonfilter.Changes
JsonWriterOptionsproperty with default value (non-indented)JsonWriterOptionsproperty initialized fromTemplateOptionsin constructorcontext.JsonWriterOptionsdirectly without argument supportTemplateOptionsandTemplateContext, and enum serializationBreaking Change
jsonfilter no longer accepts arguments. Previously, you could pass a boolean argument to control indentation (e.g.,{{ data | json: true }}). This functionality has been removed. Configure output formatting viaJsonWriterOptionsinTemplateOptionsorTemplateContextinstead.Usage
{{ data | json }}By default,
JsonWriterOptionsproduces non-indented (compact) JSON output.Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.