Skip to content

Instantly share code, notes, and snippets.

@ryan-haskell
Created September 27, 2016 04:59
Show Gist options
  • Save ryan-haskell/80a101321189d8c6d844918352ba05c9 to your computer and use it in GitHub Desktop.
Save ryan-haskell/80a101321189d8c6d844918352ba05c9 to your computer and use it in GitHub Desktop.
Elm Markdown Example
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