Skip to content
Merged
Prev Previous commit
Next Next commit
Merge branch 'main' into main
  • Loading branch information
sebastienros authored Nov 4, 2025
commit 81a6d12d392a14cbb4cce1f0ff4014637187d24a
2 changes: 1 addition & 1 deletion Fluid/Ast/MemberExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override ValueTask<FluidValue> EvaluateAsync(TemplateContext context)
return context.Undefined.Invoke(initial.Identifier);
}

return new ValueTask<FluidValue>(value);
return value;
}

start = 0;
Expand Down
8 changes: 7 additions & 1 deletion Fluid/TemplateContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Globalization;
using System.Runtime.CompilerServices;
using Fluid.Values;
using System.Text.Json;

namespace Fluid
{
Expand Down Expand Up @@ -60,6 +60,7 @@
Now = options.Now;
MaxSteps = options.MaxSteps;
ModelNamesComparer = modelNamesComparer;
JsonSerializerOptions = options.JsonSerializerOptions;
}

/// <summary>
Expand Down Expand Up @@ -116,6 +117,11 @@
/// </summary>
public TimeZoneInfo TimeZone { get; set; } = TemplateOptions.Default.TimeZone;

/// <summary>
/// Gets or sets the <see cref="JsonSerializerOptions"/> used by the <c>json</c> filter.
/// </summary>
public JsonSerializerOptions JsonSerializerOptions { get; set; } = TemplateOptions.Default.JsonSerializerOptions;

/// <summary>
/// Increments the number of statements the current template is processing.
/// </summary>
Expand Down Expand Up @@ -150,7 +156,7 @@
/// Gets or sets a model object that is used to resolve properties in a template. This object is used if local and
/// global scopes are unsuccessful.
/// </summary>
public FluidValue Model { get; }

Check failure on line 159 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 159 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 159 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 159 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

/// <summary>
/// Whether the direct properties of the Model can be accessed without being registered. Default is <code>true</code>.
Expand Down Expand Up @@ -230,7 +236,7 @@
/// Gets a value from the context.
/// </summary>
/// <param name="name">The name of the value.</param>
public FluidValue GetValue(string name)

Check failure on line 239 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 239 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 239 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 239 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)
{
return LocalScope.GetValue(name);
}
Expand All @@ -241,7 +247,7 @@
/// <param name="name">The name of the value.</param>
/// <param name="value">The value to set.</param>
/// <returns></returns>
public TemplateContext SetValue(string name, FluidValue value)

Check failure on line 250 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 250 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)
{
LocalScope.SetValue(name, value);
return this;
Expand Down Expand Up @@ -280,7 +286,7 @@
return context.SetValue(name, FluidValue.Create(value, context.Options));
}

public static TemplateContext SetValue(this TemplateContext context, string name, Func<FluidValue> factory)

Check failure on line 289 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 289 in Fluid/TemplateContext.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'FluidValue' could not be found (are you missing a using directive or an assembly reference?)
{
return context.SetValue(name, new FactoryValue(factory));
}
Expand Down
18 changes: 17 additions & 1 deletion Fluid/TemplateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using Fluid.Filters;
using Fluid.Values;
using Microsoft.Extensions.FileProviders;
using System.Globalization;

Check failure on line 6 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The using directive for 'System.Globalization' appeared previously in this namespace

Check failure on line 6 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The using directive for 'System.Globalization' appeared previously in this namespace

Check failure on line 6 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The using directive for 'System.Globalization' appeared previously in this namespace

Check failure on line 6 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The using directive for 'System.Globalization' appeared previously in this namespace
using System.Text.Encodings.Web;

Check failure on line 7 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The using directive for 'System.Text.Encodings.Web' appeared previously in this namespace

Check failure on line 7 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The using directive for 'System.Text.Encodings.Web' appeared previously in this namespace

Check failure on line 7 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The using directive for 'System.Text.Encodings.Web' appeared previously in this namespace

Check failure on line 7 in Fluid/TemplateOptions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The using directive for 'System.Text.Encodings.Web' appeared previously in this namespace
using System.Text.Json;

namespace Fluid
{
Expand Down Expand Up @@ -112,7 +115,20 @@
/// <summary>
/// Gets or sets the <see cref="JavaScriptEncoder" /> instance used by the <c>json</c> filter.
/// </summary>
public JavaScriptEncoder JavaScriptEncoder { get; set; } = DefaultJavaScriptEncoder;
[Obsolete("Use JsonSerializerOptions.Encoder instead. This property will be removed in a future version.")]
public JavaScriptEncoder JavaScriptEncoder
{
get => JsonSerializerOptions.Encoder;
set => JsonSerializerOptions.Encoder = value;
}

/// <summary>
/// Gets or sets the <see cref="JsonSerializerOptions"/> used by the <c>json</c> filter.
/// </summary>
public JsonSerializerOptions JsonSerializerOptions { get; set; } = new JsonSerializerOptions
{
Encoder = DefaultJavaScriptEncoder
};

/// <summary>
/// Gets or sets the default trimming rules.
Expand Down
4 changes: 2 additions & 2 deletions Fluid/Values/ObjectValueBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override ValueTask<FluidValue> GetValueAsync(string name, TemplateContext

if (directValue != null)
{
return new ValueTask<FluidValue>(Create(directValue, context.Options));
return FluidValue.Create(directValue, context.Options);
}
}

Expand All @@ -87,7 +87,7 @@ public override ValueTask<FluidValue> GetValueAsync(string name, TemplateContext
return context.Undefined.Invoke(name);
}

return new ValueTask<FluidValue>(NilValue.Instance);
return NilValue.Instance;


static async ValueTask<FluidValue> Awaited(
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.