Created
September 27, 2016 04:59
-
-
Save ryan-haskell/80a101321189d8c6d844918352ba05c9 to your computer and use it in GitHub Desktop.
Elm Markdown Example
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
import Html exposing (..) | |
import Html.App as Html | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (onInput) | |
import String | |
import Markdown | |
main = | |
Html.beginnerProgram | |
{ model = model | |
, view = view | |
, update = update | |
} | |
-- MODEL | |
type alias Model = { markdown: String } | |
model : Model | |
model = | |
Model "" | |
-- UPDATE | |
type Msg | |
= Change String | |
update : Msg -> Model -> Model | |
update msg model = | |
case msg of | |
Change markdown -> | |
{ model | markdown = markdown } | |
-- VIEW | |
view : Model -> Html Msg | |
view model = | |
div [class "container"] | |
[ textarea [placeholder "Enter markdown here...", onInput Change] [] | |
, Markdown.toHtml [] model.markdown | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment