Skip to content

Commit

Permalink
+ (Lava) Fixed an issue with combined person data getting double enco…
Browse files Browse the repository at this point in the history
…ded in the merge template process (Fixes #4884).
  • Loading branch information
crayzd92 committed Jan 21, 2022
1 parent 3bcdde4 commit 913f497
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions DotLiquid/Variable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,16 @@ public Variable(string markup)

public void Render(Context context, TextWriter result)
{
object output = RenderInternal(context);
// Do not apply transforms here as it will be done below.
object output = RenderInternal(context, false);

if (output is ILiquidizable)
output = null;

if (output != null)
{
// see if this context has a ValueTypeTranformer for the type
var transformer = context.GetValueTypeTransformer(output.GetType());
if (transformer == null)
{
// if the context doesn't have a ValueTypeTranformer for the type, get the global one (if there is one)
transformer = Template.GetValueTypeTransformer(output.GetType());
}

if(transformer != null)
output = transformer(output);
// Apply any required transforms to the context value prior to passing it to the filter pipeline.
output = ApplyValueTypeTransforms( context, output );

string outputString;
if (output is IEnumerable)
Expand All @@ -95,15 +88,18 @@ public void Render(Context context, TextWriter result)
}
}

private object RenderInternal(Context context)
private object RenderInternal(Context context, bool applyTransforms = true)
{
if (Name == null)
return null;

object output = context[Name];

// Apply any required transforms to the context value prior to passing it to the filter pipeline.
output = ApplyValueTypeTransforms( context, output );
if ( applyTransforms )
{
// Apply any required transforms to the context value prior to passing it to the filter pipeline.
output = ApplyValueTypeTransforms( context, output );
}

Filters.ToList().ForEach(filter =>
{
Expand Down

0 comments on commit 913f497

Please sign in to comment.