Thanks Matthew for info and good starting points.

Here are results of my research, maybe someone will be looking for it as me 
:)

https://github.com/eeue56/elm-static-site - this repo currently uses elm 
0.16. There is a call with 'renderer' which can't be provided in 0.17.

I've managed to render elm files with node/express thanks 
to https://github.com/tmpvar/jsdom

app.get('/index', function(req, res) {
    var Elm = require(path.join(rootPath, 'dist/compiled_elm.js'));
    jsdom.env(
        path.join(rootPath, 'dist/index.html'), //with included script src 
to compiled_elm.js
        function (err,window) {
            if (err != null) {
                return console.error("error", err);
            }
            document = window.document;
            Elm.Main.embed(document.getElementById('main'));
            window.setTimeout(function() {
                res.render('ssr', {
                    head: document.head.innerHTML,
                    body: document.body.innerHTML
                })
            }, 100)
        }
    );
});

And here is rendered ssr.pug view
html
head!= head
body!= body



Other approach may be 
with https://github.com/eeue56/elm-server-side-renderer
My first impression was that it can compile only single divs, but eeue56 
said that it can compile whole view and is used in testing for last 6 
months, so... my impression was wrong.
This compiler is written in ELM so it is great if you want to produce HTML 
from ELM, or...
you can spawn elm worker to compile it under any server or...
you can write tiny elm server for handling elm files with server side 
rendering, caching etc...



Anyway as Matthew posted Server Side Rendering will be in 0.18. 
0.18 is planned for October - it isn't official claim, but only loose 
information.




W dniu niedziela, 28 sierpnia 2016 19:13:43 UTC+2 użytkownik Matthew 
Griffith napisał:
>
> Hi Robert,
>
> Check out: https://github.com/eeue56/elm-static-site
>
> Also, it looks like server side rendering is on the docket for the next 
> major revision of elm, 0.18 - 
> https://groups.google.com/forum/#!topic/elm-dev/u66_K3AbqIM
>
>
>
>
> On Sunday, August 28, 2016 at 1:09:46 PM UTC-4, Robert S wrote:
>>
>> Hey, I'm going to move my 23KLOC (Coffeescript) angular 1.5 SPA 
>> application to... primarily React+Redux, but I found elm and I'm reviewing 
>> if it fits my requirements.
>>
>> *My first concern is Server Side Rendering (SSR) for SEO and fast page 
>> loading. *
>> I found https://github.com/NoRedInk/take-home but as I see it is 
>> approach to replace PHP with ELM, than to provide SSR for single page app. 
>> Also there is 
>> http://blog.overstuffedgorilla.com/server-side-elm-with-phoenix/ with 
>> source at https://github.com/hassox/phoenix_elm
>> but I can't get it to work and evaluate with Windows 10... What's more I 
>> completely don't understand what's going on there... Elixir is a black 
>> magic for me :/
>>
>> Is there any way for production application to render with Node? The best 
>> would be with precompiled elm? Without this I'll have to drop ELM and go 
>> with React :(
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to