-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "flags: {}" to default Elm.Main.init in index.html #1821
Comments
This is not needed, use
You can compile it to index.html and test it. There is an example in the guide using it there. |
Ha, it'd be nice if that was a little clearer in the docs! My solution was this build script:
Your solution works just as well and with way more elegance. |
I agree that it would be nice if it was explicitly described in the flags section of the guide for example. You could open an issue or PR in the guide instead: https://github.com/evancz/guide.elm-lang.org |
TLDR: when elm make src/main.elm generates index.html, have it add in a default flags:{} argument. Then users who wish to use Browser.Document to make a single page with a title can do so by handling an empty flags arg in their init function. If the user chooses Browser.sandbox, the extra flags arg is just ignored.
Motivation:
I want to make a simple self contained one page app - all code in index.html. I'd like to set the title, so that means using Browser.Document.
The problem is that document requires an init function that takes a flag: argument. Index.html does not supply this.
I have the option of editing in an argument in the generated index.html after every compile, or going to a separate index.html and main.js, which I don't want to do for this no-server page.
The text was updated successfully, but these errors were encountered: