Skip to content

Commit

Permalink
Removed MVCUseTemplateCache (duplicated of TMVCConfigKey.ViewCache)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Sep 11, 2024
1 parent b96dc56 commit dc04b27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
14 changes: 7 additions & 7 deletions ideexpert/DMVC.Expert.CodeGen.Commands.pas
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ procedure TUnitControllerControllerDeclarationCommand.ExecuteImplementation(
end;
Section
.AppendLine(' //use Context property to access to the HTTP request and response')
.AppendLine(' Result := ''Hello DelphiMVCFramework World'';')
.AppendLine(' Result := ''<p>Hello <strong>DelphiMVCFramework</strong> World</p>'' + ')
.AppendLine(' ''<p><small>dmvcframework-'' + DMVCFRAMEWORK_VERSION + ''</small></p>'';')
.AppendLine('end;')
.AppendLine
.AppendLine('function ' + Model[TConfigKey.controller_classname] + '.GetReversedString(const Value: String): String;')
Expand Down Expand Up @@ -665,6 +666,7 @@ .AppendLine(' ' + Model[TConfigKey.controller_classname] + ' = class(TMVCCo
.AppendLine(' public')
.AppendLine(' [MVCPath]')
.AppendLine(' [MVCHTTPMethod([httpGET])]')
.AppendLine(' [MVCProduces(TMVCMediaType.TEXT_HTML)]')
.AppendLine(' function Index: String;')
.AppendLine
.AppendLine(' [MVCPath(''/reversedstrings/($Value)'')]')
Expand Down Expand Up @@ -1045,8 +1047,6 @@ procedure TUnitMainBeginEndCommand.ExecuteImplementation(Section: TStringBuilder
.AppendLine(' // UseConsoleLogger defines if logs must be emitted to also the console (if available).')
.AppendLine(' UseConsoleLogger := True;')
.AppendLine()
.AppendLine(' // MVCUseTemplatesCache allows to cache compiled templates on disk for a faster future execution (if engine supports it).')
.AppendLine(' MVCUseTemplatesCache := True;')
.AppendLine()
.AppendLine(' LogI(''** DMVCFramework Server ** build '' + DMVCFRAMEWORK_VERSION);');

Expand Down Expand Up @@ -1396,12 +1396,12 @@ procedure TUnitTemplateProHelpersDeclarationCommand.ExecuteImplementation(
.AppendLine(' TemplatePro, System.SysUtils;')
.AppendLine
.AppendLine
.AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray<string>): string;')
.AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray<string>): TValue;')
.AppendLine('begin')
.AppendLine(' Result := Value.ToString + '' (I''''m The MyHelper1)'';')
.AppendLine('end;')
.AppendLine
.AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray<string>): string;')
.AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray<string>): TValue;')
.AppendLine('begin')
.AppendLine(' Result := Value.ToString + '' (I''''m The MyHelper2)'';')
.AppendLine('end;')
Expand Down Expand Up @@ -1452,8 +1452,8 @@ procedure TUnitTemplateProHelpersDeclarationCommand.ExecuteInterface(
.AppendLine('uses')
.AppendLine(' System.Rtti;')
.AppendLine
.AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray<string>): string;')
.AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray<string>): string;')
.AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray<string>): TValue;')
.AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray<string>): TValue;')
.AppendLine
.AppendLine
.AppendLine('procedure TemplateProContextConfigure;')
Expand Down
4 changes: 0 additions & 4 deletions sources/MVCFramework.Commons.pas
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,6 @@ TMVCHTTPStatusCode = record
/// </summary>
MVCSerializeNulls: Boolean = True;

/// <summary>
/// If "true" server side views templates are cached on disk for better performance.
/// </summary>
MVCUseTemplatesCache: Boolean = True;
{ GLOBAL CONFIG VARS // END}


Expand Down
5 changes: 1 addition & 4 deletions sources/MVCFramework.View.Renderers.Mustache.pas
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ implementation
TSynMustacheAccess = class(TSynMustache)
end;




var
gPartialsLoaded : Boolean = False;
gHelpersLoaded : Boolean = False;
Expand Down Expand Up @@ -139,7 +136,7 @@ procedure TMVCMustacheViewEngine.Execute(const ViewName: string; const Builder:
begin
PrepareModels;
lViewFileName := GetRealFileName(ViewName);
if not FileExists(lViewFileName) then
if lViewFileName.IsEmpty then
raise EMVCFrameworkViewException.CreateFmt('View [%s] not found', [ViewName]);
lViewTemplate := StringToUTF8(TFile.ReadAllText(lViewFileName, TEncoding.UTF8));
lViewEngine := TSynMustache.Parse(lViewTemplate);
Expand Down
7 changes: 4 additions & 3 deletions sources/MVCFramework.View.Renderers.TemplatePro.pas
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ procedure TMVCTemplateProViewEngine.Execute(const ViewName: string; const Builde
begin
lUseCompiledVersion := False;
lViewFileName := GetRealFileName(ViewName);

if MVCUseTemplatesCache then
if lViewFileName.IsEmpty then
raise EMVCFrameworkViewException.CreateFmt('View [%s] not found', [ViewName]);
if FUseViewCache then
begin
lCacheDir := TPath.Combine(TPath.GetDirectoryName(lViewFileName), '__cache__');
TDirectory.CreateDirectory(lCacheDir);
Expand Down Expand Up @@ -151,7 +152,7 @@ procedure TMVCTemplateProViewEngine.Execute(const ViewName: string; const Builde
try
lViewTemplate := TFile.ReadAllText(lViewFileName);
lCompiledTemplate := lTP.Compile(lViewTemplate, lViewFileName);
if MVCUseTemplatesCache then
if FUseViewCache then
begin
lCompiledTemplate.SaveToFile(lCompiledViewFileName);
end;
Expand Down

0 comments on commit dc04b27

Please sign in to comment.