Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/miyamoen/elm-route-builder

Builder for Route that has URL parser and URL builder.
https://github.com/miyamoen/elm-route-builder

elm

Last synced: 20 days ago
JSON representation

Builder for Route that has URL parser and URL builder.

Awesome Lists containing this project

README

        

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

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

```elm
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 }
```