bigos
July 16, 2025, 9:50am
#1
In the counter app there is a HTML fragment that invokes PureScript.
Guide - Halogen Guide
<script src="./index.js" type="module"></script>
How do I modify it so I can configure the initial state in the HTML file and can change the initial state without changing the code of PureScript counter?
bigos
July 16, 2025, 12:17pm
#2
Lucas DiCioccio’s Blog - How I write PureScript web-apps: Part-III
has example
<script
scr="/js/my-app.js"
data-my-app--api-endpoint="https://example.com/"
data-my-app--api-key="0xdeadb33f"
>
this seems to do what I need, but how do I do it in the context of basic halogen counter?
bigos
July 16, 2025, 3:10pm
#3
I had enough of this nonsense.
I will try flame.
bigos
July 16, 2025, 4:06pm
#4
where
go script =
do
( TagInsertionConfig
<$> getAttribute "data-my-app--api-endpoint" elem
<*> getAttribute "data-my-app--api-key" elem
)
where
elem = HTMLScript.toElement script
main ∷ Effect Unit
main = do
w <- window
config <- readConfig w
FAE.mount_ (QuerySelector "#flame")
{ init: init :> Just config
, subscribe: []
, update
, view
}
this is getting closer, but still have errors i do not understand
bigos
July 17, 2025, 7:36pm
#5
I reached the point where I can read the flags, as discussed in other threads.
After a break, I will have to create a working example and maybe ask more questions on improving it.