Skip to content

Instantly share code, notes, and snippets.

@SirmaXX
Last active August 22, 2019 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SirmaXX/27891457780a402a2761fbed9633a43b to your computer and use it in GitHub Desktop.
Save SirmaXX/27891457780a402a2761fbed9633a43b to your computer and use it in GitHub Desktop.
Flag example for newbies . thanks @jessta
<html>
<head>
<style>
/* you can style your program here */
</style>
<script src="main.js"></script>
</head>
<body>
<main></main>
<script>
var app = Elm.Main.init({ node: document.querySelector('main'), flags: {name: "Deniz Balcı"} })
// you can use ports and stuff here
</script>
</body>
</html>
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
--thanks jessta
type alias Model =
{ name : String }
init : {name: String} -> ( Model, Cmd Msg )
init flags = ({name = flags.name}, Cmd.none)
type Msg
= Increment
| Decrement
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model = (model, Cmd.none)
view : Model -> Html Msg
view model =
div [][ text ("Hi, "++model.name)]
main : Program {name: String} Model Msg
main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = \_ -> Sub.none
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment