#1 2023-08-22 21:32:40

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

mORMot2 + JavaScript client

I'll be starting a new webbased application and idea is to use mormot mvc app for serverside with Mustache templates for UI and javascript for client side.

Main question is what others use for client side java script development? Ideally I would like to write pascal code that's compiled to JS.

In the past I've used SmartMobileStudio but since that's dead I'm looking for alternatives, I do not care about UI components since I'll handle that directly in html files.

So far I'm considering:
- pas2js, with Lazarus/Delphi as editor.
- DWScript, question is what to use as editor?
- TMS WebCore, I think it uses Delphi as editor

I would be grateful to hear about other people experience/impressions with above tools alone or in combination with mORMot, also if I should consider some other toools (preferably opensource)?

Offline

#2 2023-08-23 06:21:44

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

Re: mORMot2 + JavaScript client

pas2js seems like the right choice in current context.

IIRC the DWSscript to javascript transpyler is not included any more in github, and it is Delphi and Windows only.
TMS WebCore uses pas2js internally.

But I never used pas2js in combination with mORMot yet.

Offline

#3 2023-08-23 07:36:24

ttomas
Member
Registered: 2013-03-08
Posts: 119

Re: mORMot2 + JavaScript client

Depend of type of your web app. Do you really need JS?
I build some internal projects with mormot mvc + mustache + htmx + Bootstrap5 and I will recommend to try htmx ( https://htmx.org/ ).

Offline

#4 2023-08-23 12:13:02

tbo
Member
Registered: 2015-04-20
Posts: 335

Re: mORMot2 + JavaScript client

If your Wep-App has only a few pages, then mORMot MVC and JavaScript with a CSS Framework (Bootstrap, Bulma, TailwindCSS) is a good choice. If there are more, then TMS WebCore is worth a look. I've had a license for 3 years. Only use WebCore VSC, which works well for me.

With best regards
Thomas

Offline

#5 2023-08-23 12:53:30

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

Re: mORMot2 + JavaScript client

I did not know about htmx @ttomos and its sounds very simple and easy to work with, especially with a mORMot web server and Mustache templates.

For authentication and security, a regular binary cookie, as used with MVC mustache TMvcSessionWithCookies, should be a native way of using htmx on the client side.

Offline

#6 2023-08-23 14:22:17

ttomas
Member
Registered: 2013-03-08
Posts: 119

Re: mORMot2 + JavaScript client

Yes @ab, almost no change in mormot mvc application.
Some hint, look for HX-Request in header, it is needed if user refresh page.
Just add this code in the end of procedure GetViewInfo, in mvc example.

  if context.Request.InHeader['HX-Request']<>'' then
  begin
    _ObjAddProps(['Htmx', _Obj([
        'HX-Request', context.Request.InHeader['HX-Request'],
        'HX-Trigger', context.Request.InHeader['HX-Trigger'],
        'HX-Trigger-Name', context.Request.InHeader['HX-Trigger-Name'],
        'HX-Target', context.Request.InHeader['HX-Target'],
        'HX-Prompt', context.Request.InHeader['HX-Prompt']
       ])], info);
  end;

Then in template you can use

{{^main.Htmx}} {{>header}} {{>masthead}} {{/main.Htmx}}
<!-- your page -->
{{^main.Htmx}} {{>footer}} {{/main.Htmx}}

Offline

#7 2023-08-23 14:29:20

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

Re: mORMot2 + JavaScript client

> pas2js seems like the right choice in current context.

Do you know is it comparable to DWScript capabilities?

> IIRC the DWSscript to javascript transpyler is not included any more in github, and it is Delphi and Windows only.

I am working on Windows so that's fine with me.

Their main page is at https://bitbucket.org/egrange/dwscript/src/master/ with mirror on github, it's still active with updates every so often.

> Depend of type of your web app. Do you really need JS?

I think so, it has to include offline mode (I'll try that via service workers) and some processing on client side.

> I build some internal projects with mormot mvc + mustache + htmx + Bootstrap5 and I will recommend to try htmx

Thanks, I've heard about htmx before but haven't tried it yet.
Do you create a method based functions on mORMot side that you call from htmx?

Offline

#8 2023-08-23 23:04:42

rdevine
Member
Registered: 2014-02-20
Posts: 43

Re: mORMot2 + JavaScript client

I've been using TMS WebCore with mORMot for a while now and it works great - the pas2js compiler is just fantastic. It might also be worth taking a look at pas2js in Lazarus.

Since SMS died, DWScript is now available through the Quartex project. I'm planning to take a look at it soon - it certainly looks a bit more complete than SMS ever was.

Cheers, Bob

Offline

#9 2023-08-24 08:19:05

ttomas
Member
Registered: 2013-03-08
Posts: 119

Re: mORMot2 + JavaScript client

> I think so, it has to include offline mode (I'll try that via service workers) and some processing on client side.
In that case you must build JS application using JS,TS,pas2js or DWScript and use mormot as API rest server.

> Thanks, I've heard about htmx before but haven't tried it yet.
> Do you create a method based functions on mORMot side that you call from htmx?
No I don't use method based functions, only mormot MVC app. htmx expect HTML response, not json and replace only part of HTML in your browser. Browser don't need to parse json data and create/modify DOM, just replace/add/delete some part of HTML in DOM. Easy way to transform SSR app to SPA app.

Offline

#10 2023-08-25 11:20:02

Horbs
Member
Registered: 2014-04-20
Posts: 22

Re: mORMot2 + JavaScript client

igors233 wrote:

I'll be starting a new webbased application and idea is to use mormot mvc app for serverside with Mustache templates for UI and javascript for client side.

Main question is what others use for client side java script development? Ideally I would like to write pascal code that's compiled to JS.
...


I closely examined most of the Pascal related web development applications over a number of years, and for me the standout solution was Elevate Web Builder both because of it's excellent architecture, delphi like IDE and form designer, and excellent visual controls.

So it's well worth a look (and it's very reasonably priced).

Let me know if you need further info (I've been using it as a mORMot client for some years now).

Offline

#11 2023-08-25 14:08:56

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

Re: mORMot2 + JavaScript client

> I closely examined most of the Pascal related web development applications over a number of years, and for me the standout
> solution was Elevate Web Builder both because of it's excellent architecture, delphi like IDE and form designer, and excellent visual controls.
> So it's well worth a look (and it's very reasonably priced).
> Let me know if you need further info (I've been using it as a mORMot client for some years now).

Thanks, I've tried EWB but decided on SMS and that's abandon now.
Do you know what kind of compiler EWB uses, is it a proprietary or DWScript?
For me UI and html controls are not important, I've did it for years and it's hard to maintain or change. What I'm doing now is create UI in html with mustache template and bootstrap and so UI can be changed by others (designer) and I just focus on code side.

Offline

#12 2023-08-26 10:51:18

Horbs
Member
Registered: 2014-04-20
Posts: 22

Re: mORMot2 + JavaScript client

igors233 wrote:

...
Do you know what kind of compiler EWB uses, is it a proprietary or DWScript?
For me UI and html controls are not important, I've did it for years and it's hard to maintain or change. What I'm doing now is create UI in html with mustache template and bootstrap and so UI can be changed by others (designer) and I just focus on code side.

Understood Igor.
Had a search through the EWB docs but cant find out which transpiler it's using.

This might be worth a look though (I haven't studied it in any detail yet) :
    https://quartexdeveloper.com/
You'll be familiar with the author. The payment system looks kind of strange though.

Offline

#13 2023-08-26 11:12:14

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

Re: mORMot2 + JavaScript client

I would perhaps not trust Quartex at 100% for commercial projects in the long term, because its author is very passionate and may not be able to continue its support for the long term.
We have seen all the difficulties with SMS in the last years.

EWB sounds like a more stable approach.
The company behind it https://www.elevatesoft.com/about is very small (perhaps even a one-man company), but it/he has proven to be reliable and supporting its products for the very long term.
If you want a desktop-like RAD-oriented Web UI, this is a good option.

EWB has its own transpiler IIRC, which is not bad at all, perhaps a little behind DWS or pas2JS in terms of syntax.
The most evolving transpiler is clearly pas2JS, because there is the FPC foundation behind it.

Offline

#14 2023-08-26 14:29:16

rdevine
Member
Registered: 2014-02-20
Posts: 43

Re: mORMot2 + JavaScript client

Yes the pas2js compiler is definitely the lowest risk option for sure. DWScript is very nice but it's just one developer. In theory I guess Quartex could allow switchable compilers but I've no idea if it's on the roadmap. EWB is AFAIK a one-man operation. It uses a proprietary compiler that is quite primitive compared to pas2js (e.g. it doesn't even have interfaces). It's fine if you're doing old fashioned "double-click-on-a-button-and-code-the-handler" style development. I've owned (and used) EWB and SMS over the years and WebCore/pas2js is by far the best so far (although I haven't given Quartex a serious look yet).

Cheers, Bob

Offline

Board footer

Powered by FluxBB