I am experimenting with view functions that produce both html content and the style that should be applied to that markup, as in
myView : Model -> ( Html msg, List CssRule ) So far, I have been rendering the above by creating a <style> tag inside the <body>: this works great but it is not compliant, so I want to find a way to insert the styling in the <head>. I can do this with a port, but where do I execute it? One solution would be to execute myView inside the program's update cycle, store the resulting Html in the model, and have a dummy program view function that just produces the pre-rendered html content stored in the model, but seems a really weird thing to do and I don't know how it would impact performance. update msg model = let ... ( html, style ) = myView model in ( { model | renderedView = html }, portUpdateHeaderStyle style ) view model = model.renderedView The other solution would be to render everything twice, once in the program's view to get the html content, and another inside the update cycle to get the style and execute the port, but executing myView twice doesn't seem great for performance. Is there a better way? -- 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.