Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Elm Template for Page with Multiple Views
# Definitely will be needed
NoRedInk/elm-decode-pipeline
elm-lang/core
elm-lang/dom
elm-lang/html
elm-lang/http
elm-lang/navigation
evancz/url-parser
lukewestby/elm-http-builder
rgrempel/elm-route-url
# Possibly needed, don't remember exactly
elm-community/json-extra
module TEMPLATE exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Http exposing (..)
import HttpBuilder exposing (..)
import Navigation exposing (Location)
import RouteUrl exposing (RouteUrlProgram, UrlChange)
import UrlParser exposing ((</>), string, parsePath)
-- Model --
type ViewMode
= Mode1
| Mode2
type alias Model =
{ viewMode : ViewMode
}
initialModel : Model
initialModel =
{ viewMode = Mode1
}
init : ( Model, Cmd Msg )
init =
( initialModel, Cmd.none )
-- Update --
type Msg
= Noop
| ViewMode1
| ViewMode2
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Noop ->
( model, Cmd.none )
ViewMode1 ->
( model, Cmd.none )
ViewMode2 ->
( model, Cmd.none )
delta2url : Model -> Model -> Maybe UrlChange
delta2url previous current =
Nothing
location2messages : Location -> List Msg
location2messages location =
[]
-- View --
view : Model -> Html Msg
view model =
div []
[ h1 [] [ text "Hello, World!" ]
]
-- Subscriptions --
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- Main --
main : RouteUrlProgram Never Model Msg
main =
RouteUrl.program
{ init = init
, update = update
, view = view
, subscriptions = subscriptions
, delta2url = delta2url
, location2messages = location2messages
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.