Skip to content

Instantly share code, notes, and snippets.

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 sethlivingston/9ff35bd9d4c7c7ac89b30218014aa277 to your computer and use it in GitHub Desktop.
Save sethlivingston/9ff35bd9d4c7c7ac89b30218014aa277 to your computer and use it in GitHub Desktop.
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