diff --git a/samples/htmx_website_with_templatepro/bin/templates/pages/customers.html b/samples/htmx_website_with_templatepro/bin/templates/pages/customers.html index 74915a80..d0835fbe 100644 --- a/samples/htmx_website_with_templatepro/bin/templates/pages/customers.html +++ b/samples/htmx_website_with_templatepro/bin/templates/pages/customers.html @@ -19,7 +19,7 @@ {{:cust.first_name}} {{:cust.last_name}} {{:cust.country|capitalize}} - {{:cust.dob}}{{if cust.dob|ge,"2000/01/01"}}📅{{endif}} + {{:cust.dob|datetostr}}{{if cust.dob|ge,"2000/01/01"}}📅{{endif}} {{endfor}} {{endif}} diff --git a/samples/htmx_website_with_templatepro/htmx_website_with_templatepro.dproj b/samples/htmx_website_with_templatepro/htmx_website_with_templatepro.dproj index 0f6506e1..f101f85c 100644 --- a/samples/htmx_website_with_templatepro/htmx_website_with_templatepro.dproj +++ b/samples/htmx_website_with_templatepro/htmx_website_with_templatepro.dproj @@ -6,10 +6,10 @@ True Debug Win32 - htmx_website_with_templatepro - 1 + 129 Console htmx_website_with_templatepro.dpr + htmx_website_with_templatepro true @@ -44,6 +44,12 @@ Base true + + true + Cfg_1 + true + true + true Cfg_1 @@ -104,6 +110,9 @@ true true + + C:\DEV\dmvcframework\sources\;$(Debugger_DebugSourcePath) + false 1033 @@ -179,6 +188,12 @@ true + + + htmx_website_with_templatepro + true + + 1 @@ -1024,7 +1039,7 @@ False False - False + True True False diff --git a/samples/instant_search_with_htmx_and_templatepro/Controllers.BooksU.pas b/samples/instant_search_with_htmx_and_templatepro/Controllers.BooksU.pas index bdf29f7c..0ad1bfe0 100644 --- a/samples/instant_search_with_htmx_and_templatepro/Controllers.BooksU.pas +++ b/samples/instant_search_with_htmx_and_templatepro/Controllers.BooksU.pas @@ -9,7 +9,6 @@ type [MVCPath] TBooksController = class(TMVCController) public - [MVCPath] [MVCPath] function Index([MVCFromQueryString('query','')] SearchQueryText: String): String; diff --git a/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dpr b/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dpr index 16f5df15..bc52cb44 100644 --- a/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dpr +++ b/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dpr @@ -30,7 +30,7 @@ var LServer: TIdHTTPWebBrokerBridge; begin ReportMemoryLeaksOnShutdown := True; - LogI(Format('Starting HTTP Server on port %d', [APort])); + LogI(Format('Starting HTTP Server on http://localhost:%d', [APort])); LServer := TIdHTTPWebBrokerBridge.Create(nil); try LServer.DefaultPort := APort; diff --git a/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dproj b/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dproj index 63d5b8b8..8fd4cdd0 100644 --- a/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dproj +++ b/samples/serversideviews_templatepro/ServerSideViewsTemplatePro.dproj @@ -6,7 +6,7 @@ ServerSideViewsTemplatePro.dpr True Debug - Win64 + Win32 3 Console ServerSideViewsTemplatePro @@ -149,7 +149,6 @@ - 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;