mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 04:43:03 +03:00
Extract helper.
This commit is contained in:
parent
652215fdf9
commit
3301d3110c
@ -368,17 +368,8 @@ otherFile routes phaseString =
|
|||||||
, just =
|
, just =
|
||||||
( "route"
|
( "route"
|
||||||
, \justRoute ->
|
, \justRoute ->
|
||||||
Elm.Case.custom justRoute
|
branchHelper justRoute
|
||||||
Type.unit
|
(\route innerRecord ->
|
||||||
(routes
|
|
||||||
|> List.map
|
|
||||||
(\route ->
|
|
||||||
let
|
|
||||||
moduleName =
|
|
||||||
"Route." ++ (RoutePattern.toModuleName route |> String.join "__")
|
|
||||||
|
|
||||||
expression : Elm.Expression -> Elm.Expression
|
|
||||||
expression innerRecord =
|
|
||||||
Elm.apply
|
Elm.apply
|
||||||
(Elm.value
|
(Elm.value
|
||||||
{ annotation = Nothing
|
{ annotation = Nothing
|
||||||
@ -399,22 +390,11 @@ otherFile routes phaseString =
|
|||||||
]
|
]
|
||||||
, Elm.fn ( "param", Nothing )
|
, Elm.fn ( "param", Nothing )
|
||||||
(\param ->
|
(\param ->
|
||||||
Elm.list []
|
-- TODO not implemented
|
||||||
|
todo
|
||||||
)
|
)
|
||||||
, innerRecord
|
, innerRecord |> Maybe.withDefault (Elm.record [])
|
||||||
]
|
]
|
||||||
in
|
|
||||||
if RoutePattern.hasRouteParams route then
|
|
||||||
Elm.Case.branch1 moduleName
|
|
||||||
( "routeParams", Type.unit )
|
|
||||||
(\routeParams ->
|
|
||||||
expression routeParams
|
|
||||||
)
|
|
||||||
|
|
||||||
else
|
|
||||||
Elm.Case.branch0 moduleName
|
|
||||||
(expression (Elm.record []))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -422,6 +402,31 @@ otherFile routes phaseString =
|
|||||||
(Gen.DataSource.annotation_.dataSource (Type.maybe Gen.Pages.Internal.NotFoundReason.annotation_.notFoundReason))
|
(Gen.DataSource.annotation_.dataSource (Type.maybe Gen.Pages.Internal.NotFoundReason.annotation_.notFoundReason))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
branchHelper : Elm.Expression -> (RoutePattern -> Maybe Elm.Expression -> Elm.Expression) -> Elm.Expression
|
||||||
|
branchHelper routeExpression toInnerExpression =
|
||||||
|
Elm.Case.custom routeExpression
|
||||||
|
Type.unit
|
||||||
|
(routes
|
||||||
|
|> List.map
|
||||||
|
(\route ->
|
||||||
|
let
|
||||||
|
moduleName : String
|
||||||
|
moduleName =
|
||||||
|
"Route." ++ (RoutePattern.toModuleName route |> String.join "__")
|
||||||
|
in
|
||||||
|
if RoutePattern.hasRouteParams route then
|
||||||
|
Elm.Case.branch1 moduleName
|
||||||
|
( "routeParams", Type.unit )
|
||||||
|
(\routeParams ->
|
||||||
|
toInnerExpression route (Just routeParams)
|
||||||
|
)
|
||||||
|
|
||||||
|
else
|
||||||
|
Elm.Case.branch0 moduleName
|
||||||
|
(toInnerExpression route Nothing)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
encodeActionData :
|
encodeActionData :
|
||||||
{ declaration : Elm.Declaration
|
{ declaration : Elm.Declaration
|
||||||
, call : Elm.Expression -> Elm.Expression
|
, call : Elm.Expression -> Elm.Expression
|
||||||
|
Loading…
Reference in New Issue
Block a user