#1 2022-09-21 07:00:42

Mark
Member
Registered: 2013-11-30
Posts: 19

Mormot2 MVC TMvcRunOnRestServer void template

Hi ab,

  I find a strange issue since recent update of Mormot2 (2.0.4099), Win10.

  The MVC Server (from your example) with fMainRunner := TMvcRunOnRestServer.Create(Self);
  It always overwrites my existing html template in folder "Views" (eg. HTML file content is about -> {{! void template created for the IWebApplication.xxx View: )
 
  Any settings need ?
 
Thanks

Last edited by Mark (2022-09-22 02:14:58)

Offline

#2 2022-09-21 16:30:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Mormot2 MVC TMvcRunOnRestServer void template

Are you sure you generated the executable in the right folder?

Because on my side, if I compile it into the exe sub-folder on the sample directory, then it properly find the existing exe/Views template files.

Offline

#3 2022-09-22 02:04:47

Mark
Member
Registered: 2013-11-30
Posts: 19

Re: Mormot2 MVC TMvcRunOnRestServer void template

Hello, Ab,

The issue still remain.

I build the MVCServer sample, it is success to generate MVCServer.exe in folder "exe".

But when I run the exe,
I find that all html files (under folder Views) content updated with default void statements "{{! void template created" .

That means all the existing *.html content cleared (eg. <!DOCTYPE html> ...   >>   {{! void template created for the xxx.yyy View: ...)

I check the log, find:
0000000000000619  ! warn  {"TMvcViewsMustache(01510930)":{}}.Create: Missing View file in Default.*      << Already exists Default.html in Views folder, why cannot find?
00000000000007C4  ! warn  {"TMvcViewsMustache(01510930)":{}}.Create: Missing View file in Error.*      << Ditto
00000000000008E7  ! warn  {"TMvcViewsMustache(01510930)":{}}.Create: Missing View file in ArticleView.*      << Ditto
0000000000000AAD  ! warn  {"TMvcViewsMustache(01510930)":{}}.Create: Missing View file in AuthorView.*      << Ditto
0000000000000C2D  ! warn  {"TMvcViewsMustache(01510930)":{}}.Create: Missing View file in ArticleEdit.*      << Ditto

Win10, Mormot2 (2.0.4099), FP (3.2.2), Laz (2.2.2)

Please help !

Last edited by Mark (2022-09-26 06:46:08)

Offline

#4 2022-09-28 02:49:06

Mark
Member
Registered: 2013-11-30
Posts: 19

Re: Mormot2 MVC TMvcRunOnRestServer void template

Still clean my pre-set html templates when run the MVC Server program.

Is it wrong code calling?

Code:
fMainRunner := TMvcRunOnRestServer.Create(Self);

Offline

#5 2022-09-28 07:14:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Mormot2 MVC TMvcRunOnRestServer void template

I am not able to reproduce the problem, as I wrote above.

Please try to debug on your side in  TMvcViewsMustache.Create to see what happens.
For instance, didn't you change the ViewTemplateFolder value?

Offline

#6 2022-09-28 07:18:39

igors233
Member
Registered: 2012-09-10
Posts: 241

Re: Mormot2 MVC TMvcRunOnRestServer void template

Try to update your mORMot code with latest version.

Code is fine and it will create template with default settings, I think it's better if you specify it yourself, for example:

var
  Params: TMVCViewsMustacheParameters;
begin
  FillChar(Params, sizeof(Params), 0);
  Params.Folder := Settings.TemplatesLocation;
  Params.FileTimestampMonitorAfterSeconds := 5;
  Params.ExtensionForNotExistingTemplate := '.html';
  Params.Helpers := TSynMustache.HelpersGetStandardList;

  FViews := TMVCViewsMustache.Create(Self.Factory.InterfaceTypeInfo, Params, FRestServer.LogClass);
  FMainRunner := TMVCRunOnRestServer.Create(Self, nil, '', FViews, [publishStatic, registerORMTableAsExpressions]);

Offline

#7 2022-09-28 11:23:05

Mark
Member
Registered: 2013-11-30
Posts: 19

Re: Mormot2 MVC TMvcRunOnRestServer void template

>>For instance, didn't you change the ViewTemplateFolder value?
I use default folder "Views" with Default.html

When I debug, (lazarus GDB always abort in some object. eg. fViews)
I find something strange but the GDB  abort, It cannot show in depth ---broken then stop dialog.

I find that the result of  if length(files) >0 then --> false
so, goto the block to create a new html template

I suspect FindTemplates() cannot get Default.html contents.
where SearchPattern --> Default.*

code:
  mormot.rest.mvc

line 1169     files := FindTemplates(SearchPattern);
line 1170       if length(files) > 0 then     <-- false

Last edited by Mark (2022-09-28 12:52:16)

Offline

Board footer

Powered by FluxBB