/elm-route-builder

Builder for Route that has URL parser and URL builder.

Primary LanguageElmBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

elm-route-builder let us define both URL builder and parser at once.

I have no MP to write document. ワタシ ニホンジン. エイゴ ニガテ

type alias BookIds =
    { libraryId : String, bookId : String }


bookRoute : Route BookIds page
bookRoute =
    root |> s "libraries" |> string .libraryId |> s "books" |> string .bookId |> dynamic BookIds


bookUrl : String
bookUrl =
    bookRoute.toString { libraryId = "図書館", bookId = "" }


bookParser : Url.Parser.Parser (BookPageModel -> BookPageModel) BookPageModel
bookParser =
    bookRoute.toParser bookPageInit


type alias BookPageModel =
    { ids : BookIds }


bookPageInit : BookIds -> BookPageModel
bookPageInit ids =
    { ids = ids }