Skip to content

Commit

Permalink
Wizard automatically add form-encoded serializer in case of SSV selec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
danieleteti committed Nov 21, 2024
1 parent 3ec15b8 commit 54f4362
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ideexpert/DMVC.Expert.CodeGen.Commands.pas
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ procedure TUnitWebModuleDeclarationCommand.ExecuteImplementation(
activerecord_con_def_name: string;
activerecord_con_def_filename: string;
default_media_type: string;
lAddURLEncodedSerializer: Boolean;
begin
inherited;

Expand Down Expand Up @@ -799,13 +800,15 @@ procedure TUnitWebModuleDeclarationCommand.ExecuteImplementation(
if Model.B[TConfigKey.program_ssv_templatepro] then
begin
Section
.AppendLine(' MVCFramework.Serializer.URLEncoded,')
.AppendLine(' MVCFramework.View.Renderers.TemplatePro,');
default_media_type := 'TMVCMediaType.TEXT_HTML';
end;

if Model.B[TConfigKey.program_ssv_webstencils] then
begin
Section
.AppendLine(' MVCFramework.Serializer.URLEncoded,')
.AppendLine(' MVCFramework.View.Renderers.WebStencils,');
default_media_type := 'TMVCMediaType.TEXT_HTML';
end;
Expand All @@ -814,6 +817,7 @@ procedure TUnitWebModuleDeclarationCommand.ExecuteImplementation(
if Model.B[TConfigKey.program_ssv_mustache] then
begin
Section
.AppendLine(' MVCFramework.Serializer.URLEncoded,')
.AppendLine(' MVCFramework.View.Renderers.Mustache,');
default_media_type := 'TMVCMediaType.TEXT_HTML';
end;
Expand Down Expand Up @@ -863,8 +867,10 @@ procedure TUnitWebModuleDeclarationCommand.ExecuteImplementation(
.AppendLine(' // Controllers - END')
.AppendLine;

lAddURLEncodedSerializer := False;
if Model.B[TConfigKey.program_ssv_templatepro] then
begin
lAddURLEncodedSerializer := True;
Section
.AppendLine(' // Server Side View')
.AppendLine(' FMVC.SetViewEngine(TMVCTemplateProViewEngine);')
Expand All @@ -874,6 +880,7 @@ procedure TUnitWebModuleDeclarationCommand.ExecuteImplementation(

if Model.B[TConfigKey.program_ssv_webstencils] then
begin
lAddURLEncodedSerializer := True;
Section
.AppendLine(' // Server Side View')
.AppendLine(' FMVC.SetViewEngine(TMVCWebStencilsViewEngine);')
Expand All @@ -883,13 +890,22 @@ procedure TUnitWebModuleDeclarationCommand.ExecuteImplementation(

if Model.B[TConfigKey.program_ssv_mustache] then
begin
lAddURLEncodedSerializer := True;
Section
.AppendLine(' // Server Side View')
.AppendLine(' FMVC.SetViewEngine(TMVCMustacheViewEngine);')
.AppendLine(' // Server Side View - END')
.AppendLine;
end;

if lAddURLEncodedSerializer then
begin
Section
.AppendLine(' // Serializers')
.AppendLine(' FMVC.AddSerializer(TMVCMediaType.APPLICATION_FORM_URLENCODED, TMVCURLEncodedSerializer.Create(nil));')
.AppendLine(' // Serializers - END')
.AppendLine;
end;

Section
.AppendLine(' // Middleware');
Expand Down

0 comments on commit 54f4362

Please sign in to comment.