Last active
August 22, 2019 18:03
-
-
Save SirmaXX/27891457780a402a2761fbed9633a43b to your computer and use it in GitHub Desktop.
Flag example for newbies . thanks @jessta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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