diff --git a/ideexpert/DMVC.Expert.CodeGen.Commands.pas b/ideexpert/DMVC.Expert.CodeGen.Commands.pas index 1bd69bbf..b2983454 100644 --- a/ideexpert/DMVC.Expert.CodeGen.Commands.pas +++ b/ideexpert/DMVC.Expert.CodeGen.Commands.pas @@ -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 := ''

Hello DelphiMVCFramework World

'' + ') + .AppendLine(' ''

dmvcframework-'' + DMVCFRAMEWORK_VERSION + ''

'';') .AppendLine('end;') .AppendLine .AppendLine('function ' + Model[TConfigKey.controller_classname] + '.GetReversedString(const Value: String): String;') @@ -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)'')]') @@ -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);'); @@ -1396,12 +1396,12 @@ procedure TUnitTemplateProHelpersDeclarationCommand.ExecuteImplementation( .AppendLine(' TemplatePro, System.SysUtils;') .AppendLine .AppendLine - .AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray): string;') + .AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray): TValue;') .AppendLine('begin') .AppendLine(' Result := Value.ToString + '' (I''''m The MyHelper1)'';') .AppendLine('end;') .AppendLine - .AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray): string;') + .AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray): TValue;') .AppendLine('begin') .AppendLine(' Result := Value.ToString + '' (I''''m The MyHelper2)'';') .AppendLine('end;') @@ -1452,8 +1452,8 @@ procedure TUnitTemplateProHelpersDeclarationCommand.ExecuteInterface( .AppendLine('uses') .AppendLine(' System.Rtti;') .AppendLine - .AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray): string;') - .AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray): string;') + .AppendLine('function MyHelper1(const Value: TValue; const Parameters: TArray): TValue;') + .AppendLine('function MyHelper2(const Value: TValue; const Parameters: TArray): TValue;') .AppendLine .AppendLine .AppendLine('procedure TemplateProContextConfigure;') diff --git a/sources/MVCFramework.Commons.pas b/sources/MVCFramework.Commons.pas index 2255e860..4e60743f 100644 --- a/sources/MVCFramework.Commons.pas +++ b/sources/MVCFramework.Commons.pas @@ -640,10 +640,6 @@ TMVCHTTPStatusCode = record /// MVCSerializeNulls: Boolean = True; - /// - /// If "true" server side views templates are cached on disk for better performance. - /// - MVCUseTemplatesCache: Boolean = True; { GLOBAL CONFIG VARS // END} diff --git a/sources/MVCFramework.View.Renderers.Mustache.pas b/sources/MVCFramework.View.Renderers.Mustache.pas index 3d2c21f4..dd0668d5 100644 --- a/sources/MVCFramework.View.Renderers.Mustache.pas +++ b/sources/MVCFramework.View.Renderers.Mustache.pas @@ -93,9 +93,6 @@ implementation TSynMustacheAccess = class(TSynMustache) end; - - - var gPartialsLoaded : Boolean = False; gHelpersLoaded : Boolean = False; @@ -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); diff --git a/sources/MVCFramework.View.Renderers.TemplatePro.pas b/sources/MVCFramework.View.Renderers.TemplatePro.pas index c36c1e4c..f42e3db7 100644 --- a/sources/MVCFramework.View.Renderers.TemplatePro.pas +++ b/sources/MVCFramework.View.Renderers.TemplatePro.pas @@ -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); @@ -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;