Fixed linux support for include and layout block in TemplatePro engine
Some checks are pending
TOC Generator / TOC Generator (push) Waiting to run

This commit is contained in:
Daniele Teti 2024-10-21 19:12:36 +02:00
parent acdec2fd44
commit 53d8efd048
2 changed files with 28 additions and 17 deletions

View File

@ -5301,28 +5301,29 @@ function TMVCBaseViewEngine.GetRealFileName(const AViewName: string): string;
var
lFileName: string;
lDefaultViewFileExtension: string;
lTemplateFolder: string;
begin
lDefaultViewFileExtension := Config[TMVCConfigKey.DefaultViewFileExtension];
lFileName := StringReplace(AViewName, '/', '\', [rfReplaceAll]);
lFileName := StringReplace(AViewName, '/', PathDelim, [rfReplaceAll]);
if (lFileName = '\') then
if (lFileName = PathDelim) then
begin
lFileName := '\index.' + lDefaultViewFileExtension
lFileName := PathDelim + 'index.' + lDefaultViewFileExtension
end
else
begin
lFileName := lFileName + '.' + lDefaultViewFileExtension;
end;
if DirectoryExists(Config[TMVCConfigKey.ViewPath]) then
lTemplateFolder := Config[TMVCConfigKey.ViewPath];
if DirectoryExists(lTemplateFolder) then
begin
lFileName := ExpandFileName(IncludeTrailingPathDelimiter(Config.Value[TMVCConfigKey.ViewPath]) +
lFileName)
lFileName := ExpandFileName(IncludeTrailingPathDelimiter(lTemplateFolder) + lFileName)
end
else
begin
lFileName := ExpandFileName(IncludeTrailingPathDelimiter(GetApplicationFileNamePath +
Config.Value[TMVCConfigKey.ViewPath]) + lFileName);
lFileName := ExpandFileName(IncludeTrailingPathDelimiter(
GetApplicationFileNamePath + lTemplateFolder) + lFileName);
end;
if FileExists(lFileName) then

View File

@ -600,7 +600,20 @@ begin
tkInt64: Result := Value.AsInt64.ToString;
tkString, tkUString, tkWString, tkLString: Result := Value.AsString;
tkWChar, tkChar: Result := Value.AsType<Char>;
tkFloat: Result := FloatToStr(Value.AsExtended, fLocaleFormatSettings);
tkFloat: begin
if Value.TypeInfo.Name = 'TDate' then
begin
Result := DateToStr(Value.AsExtended, fLocaleFormatSettings);
end
else if Value.TypeInfo.Name = 'TDateTime' then
begin
Result := DateTimeToStr(Value.AsExtended, fLocaleFormatSettings);
end
else
begin
Result := FloatToStr(Value.AsExtended, fLocaleFormatSettings);
end;
end;
tkEnumeration: Result := Value.ToString;
else
raise ETProException.Create('Unsupported type for variable "' + VarName + '"');
@ -995,6 +1008,7 @@ begin
lFoundVar := False;
lFoundFilter := False;
Step;
lRef2 := -1;
if MatchVariable(lVarName) then { variable }
begin
lFoundVar := True;
@ -1002,15 +1016,11 @@ begin
Error('Invalid variable name');
lFuncName := '';
lFuncParamsCount := -1; { -1 means "no filter applied to value" }
lRef2 := IfThen(MatchSymbol('$'), 1, -1);
// {{value$}} means no escaping
lRef2 := IfThen(MatchSymbol('$'), 1, -1); // {{value$}} means no escaping
MatchSpace;
if MatchSymbol('|') then
begin
MatchFilter(lVarName, lFuncName, lFuncParamsCount, lFuncParams);
end;
end
else if MatchSymbol('|') then
if MatchSymbol('|') then
begin
lFoundFilter := True;
MatchFilter(lVarName, lFuncName, lFuncParamsCount, lFuncParams);