diff --git a/samples/serversideviews_templatepro/bin/people.data b/samples/serversideviews_templatepro/bin/people.data
index 80a572ae..1f5be890 100644
--- a/samples/serversideviews_templatepro/bin/people.data
+++ b/samples/serversideviews_templatepro/bin/people.data
@@ -1 +1 @@
-[{"first_name":"Daniele","last_name":"Teti","age":43,"devices":[],"guid":"49E8419B66C744529D63DB292389D541"},{"first_name":"Peter","last_name":"Parker","age":23,"devices":[],"guid":"C5489969A04D4AE4B00D4FC50C8ADB5C"},{"first_name":"Bruce","last_name":"Banner","age":50,"devices":[],"guid":"B41D180F30584558B4F4A1AAF849FFA3"},{"first_name":"Sue","last_name":"Storm","age":33,"devices":[],"guid":"3F058118B8C6470D9684E127BC30A84A"},{"first_name":"Scott","last_name":"Summer","age":35,"devices":[],"guid":"3518D8C6F60E42D19C5A7250ADEADC33"},{"first_name":"Reed","last_name":"Richards","age":45,"devices":["smartphone","desktop"],"guid":"09C85C9DEB714476AADB9EB0AD689536"},{"first_name":"Paolino","last_name":"Paperino","age":34,"devices":["dumbphone","laptop"],"guid":"40E3AA589440403C851D28FD649735E8"},{"first_name":"Paolino","last_name":"Paperino","age":34,"devices":["dumbphone","laptop"],"guid":"A9F3E3B5F6D344EC93C47C6E2B721B16"}]
\ No newline at end of file
+[{"first_name":"Daniele","last_name":"Teti","age":43,"devices":[],"guid":"49E8419B66C744529D63DB292389D541"},{"first_name":"Peter","last_name":"Parker","age":23,"devices":[],"guid":"C5489969A04D4AE4B00D4FC50C8ADB5C"},{"first_name":"Bruce","last_name":"Banner","age":50,"devices":[],"guid":"B41D180F30584558B4F4A1AAF849FFA3"},{"first_name":"Sue","last_name":"Storm","age":33,"devices":[],"guid":"3F058118B8C6470D9684E127BC30A84A"},{"first_name":"Scott","last_name":"Summer","age":35,"devices":[],"guid":"3518D8C6F60E42D19C5A7250ADEADC33"},{"first_name":"Reed","last_name":"Richards","age":45,"devices":["smartphone","desktop"],"guid":"09C85C9DEB714476AADB9EB0AD689536"},{"first_name":"Paolino","last_name":"Paperino","age":34,"devices":["dumbphone","laptop"],"guid":"40E3AA589440403C851D28FD649735E8"},{"first_name":"Paolino","last_name":"Paperino","age":34,"devices":["dumbphone","laptop"],"guid":"A9F3E3B5F6D344EC93C47C6E2B721B16"},{"first_name":"Bruce","last_name":"Banner 2","age":45,"devices":["dumbphone"],"guid":"CD5DCFF20B5F45E69C78F653840B9EE5"}]
\ No newline at end of file
diff --git a/samples/serversideviews_templatepro/bin/templates/showcase.tpro b/samples/serversideviews_templatepro/bin/templates/showcase.tpro
index 2543b0ef..0dbebb18 100644
--- a/samples/serversideviews_templatepro/bin/templates/showcase.tpro
+++ b/samples/serversideviews_templatepro/bin/templates/showcase.tpro
@@ -86,7 +86,7 @@ This page is a showcase for all the TemplatePro features usable from DMVCFramewo
Using Filters
- Using syntax {{{"value as string"|uppercase}} = {{"value as string"|uppercase}} Filter "uppercase" is invoked passing "value as string" as constant value.
- - Using syntax {{{first_name!uppercase}} = {{:first_name|uppercase}} Filter "uppercase" is invoked passing the value contained in the attribute first_name.
+ - Using syntax {{{first_name|uppercase}} = {{:first_name|uppercase}} Filter "uppercase" is invoked passing the value contained in the attribute first_name.
- Helpers cannot be nested (yet)
diff --git a/sources/TemplatePro.pas b/sources/TemplatePro.pas
index b302ac80..3d6d706c 100644
--- a/sources/TemplatePro.pas
+++ b/sources/TemplatePro.pas
@@ -182,7 +182,7 @@ type
function EvaluateIfExpressionAt(var Idx: Int64): Boolean;
function GetVariables: TTProVariables;
procedure SplitVariableName(const VariableWithMember: String; out VarName, VarMembers: String);
- function ExecuteFilter(aFunctionName: string; aParameters: TArray; aValue: TValue): TValue;
+ function ExecuteFilter(aFunctionName: string; aParameters: TArray; aValue: TValue; const aVarNameWhereShoudBeApplied: String): TValue;
procedure CheckParNumber(const aHowManyPars: Integer; const aParameters: TArray); overload;
procedure CheckParNumber(const aMinParNumber, aMaxParNumber: Integer; const aParameters: TArray); overload;
function GetPseudoVariable(const VarIterator: Integer; const PseudoVarName: String): TValue; overload;
@@ -1615,7 +1615,7 @@ begin
end;
function TTProCompiledTemplate.ExecuteFilter(aFunctionName: string; aParameters: TArray;
- aValue: TValue): TValue;
+ aValue: TValue; const aVarNameWhereShoudBeApplied: String): TValue;
var
lDateValue: TDateTime;
lDateFilterFormatSetting: TFormatSettings;
@@ -1624,7 +1624,9 @@ var
lAnonFunc: TTProTemplateAnonFunction;
lIntegerPar1: Integer;
lDecimalMask: string;
+ lExecuteAsFilterOnAValue: Boolean;
begin
+ lExecuteAsFilterOnAValue := not aVarNameWhereShoudBeApplied.IsEmpty;
aFunctionName := lowercase(aFunctionName);
if SameText(aFunctionName, 'gt') then
begin
@@ -1664,7 +1666,7 @@ begin
end
else if SameText(aFunctionName, 'uppercase') then
begin
- if not aValue.IsEmpty then
+ if lExecuteAsFilterOnAValue then
begin
CheckParNumber(0, aParameters);
Result := UpperCase(aValue.AsString);
@@ -1677,7 +1679,7 @@ begin
end
else if SameText(aFunctionName, 'lowercase') then
begin
- if not aValue.IsEmpty then
+ if lExecuteAsFilterOnAValue then
begin
CheckParNumber(0, aParameters);
Result := lowercase(aValue.AsString);
@@ -1690,7 +1692,7 @@ begin
end
else if SameText(aFunctionName, 'capitalize') then
begin
- if not aValue.IsEmpty then
+ if lExecuteAsFilterOnAValue then
begin
CheckParNumber(0, aParameters);
Result := CapitalizeString(aValue.AsString, True);
@@ -1820,7 +1822,7 @@ begin
end
else if SameText(aFunctionName, 'version') then
begin
- if not aValue.IsEmpty then
+ if lExecuteAsFilterOnAValue then
begin
FunctionError(aFunctionName, 'cannot be applied to a value - [HINT] Use {{:|' + aFunctionName + '}}');
end;
@@ -3126,11 +3128,11 @@ begin
end;
case lCurrTokenType of
ttValue:
- Result := ExecuteFilter(lFilterName, lFilterParameters, GetVarAsTValue(lVarName));
+ Result := ExecuteFilter(lFilterName, lFilterParameters, GetVarAsTValue(lVarName), lVarName);
ttBoolExpression:
- Result := IsTruthy(ExecuteFilter(lFilterName, lFilterParameters, GetVarAsTValue(lVarName)));
+ Result := IsTruthy(ExecuteFilter(lFilterName, lFilterParameters, GetVarAsTValue(lVarName), lVarName));
ttLiteralString:
- Result := ExecuteFilter(lFilterName, lFilterParameters, lVarName);
+ Result := ExecuteFilter(lFilterName, lFilterParameters, lVarName, lVarName);
else
Error('Invalid token in EvaluateValue');
end;