arbitrarily moving things because im a little tipsy

This commit is contained in:
Ryan Haskell-Glatz 2019-11-13 20:33:59 -07:00
parent 0a98017329
commit 5ca17aac39

View File

@ -311,6 +311,102 @@ pages details =
} }
pagesContents : Details -> String
pagesContents details =
"""
module {{pagesModuleName}} exposing
( Model
, Msg
, page
)
import App.Page
import Layout as Layout
import Utils.Spa as Spa
import {{paramsModuleName}} as Params
import {{routeModuleName}} as Route exposing (Route)
{{pagesPageImports}}
{{pagesFolderRouteImports}}
{{pagesFolderPagesImports}}
{{pagesModelTypes}}
{{pagesMsgTypes}}
page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
page =
Spa.layout
{ view = Layout.view
, recipe =
{ init = init
, update = update
, bundle = bundle
}
}
-- RECIPES
type alias Recipe flags model msg appMsg =
Spa.Recipe flags model msg Model Msg appMsg
type alias Recipes msg =
{{pagesRecipesTypeAliases}}
recipes : Recipes msg
recipes =
{{pagesRecipesFunctions}}
-- INIT
init : Route -> Spa.Init Model Msg
init route_ =
{{pagesInitFunction}}
-- UPDATE
update : Msg -> Model -> Spa.Update Model Msg
update bigMsg bigModel =
{{pagesUpdateFunction}}
-- BUNDLE
bundle : Model -> Spa.Bundle Msg msg
bundle bigModel =
{{pagesBundleFunction}}
"""
|> String.replace "{{pagesModuleName}}" (pagesModuleName details.moduleName)
|> String.replace "{{paramsModuleName}}" (paramsModuleName details.moduleName)
|> String.replace "{{routeModuleName}}" (routeModuleName details.moduleName)
|> String.replace "{{pagesPageImports}}" (pagesPageImports details.files)
|> String.replace "{{pagesFolderRouteImports}}" (pagesFolderImports "Route" details.folders)
|> String.replace "{{pagesFolderPagesImports}}" (pagesFolderImports "Pages" details.folders)
|> String.replace "{{pagesModelTypes}}" (pagesCustomTypes "Model" details)
|> String.replace "{{pagesMsgTypes}}" (pagesCustomTypes "Msg" details)
|> String.replace "{{pagesRecipesTypeAliases}}" (pagesRecipesTypeAliases details)
|> String.replace "{{pagesRecipesFunctions}}" (pagesRecipesFunctions details)
|> String.replace "{{pagesInitFunction}}" (pagesInitFunction details)
|> String.replace "{{pagesUpdateFunction}}" (pagesUpdateFunction details)
|> String.replace "{{pagesBundleFunction}}" (pagesBundleFunction details)
|> String.trim
pagesModuleName : String -> String pagesModuleName : String -> String
pagesModuleName = pagesModuleName =
moduleNameFor "Pages" moduleNameFor "Pages"
@ -546,102 +642,6 @@ pagesToBundle item =
"Dynamic_Folder model ->\n recipes.dynamic_folder.bundle model" "Dynamic_Folder model ->\n recipes.dynamic_folder.bundle model"
pagesContents : Details -> String
pagesContents details =
"""
module {{pagesModuleName}} exposing
( Model
, Msg
, page
)
import App.Page
import Layout as Layout
import Utils.Spa as Spa
import {{paramsModuleName}} as Params
import {{routeModuleName}} as Route exposing (Route)
{{pagesPageImports}}
{{pagesFolderRouteImports}}
{{pagesFolderPagesImports}}
{{pagesModelTypes}}
{{pagesMsgTypes}}
page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
page =
Spa.layout
{ view = Layout.view
, recipe =
{ init = init
, update = update
, bundle = bundle
}
}
-- RECIPES
type alias Recipe flags model msg appMsg =
Spa.Recipe flags model msg Model Msg appMsg
type alias Recipes msg =
{{pagesRecipesTypeAliases}}
recipes : Recipes msg
recipes =
{{pagesRecipesFunctions}}
-- INIT
init : Route -> Spa.Init Model Msg
init route_ =
{{pagesInitFunction}}
-- UPDATE
update : Msg -> Model -> Spa.Update Model Msg
update bigMsg bigModel =
{{pagesUpdateFunction}}
-- BUNDLE
bundle : Model -> Spa.Bundle Msg msg
bundle bigModel =
{{pagesBundleFunction}}
"""
|> String.replace "{{pagesModuleName}}" (pagesModuleName details.moduleName)
|> String.replace "{{paramsModuleName}}" (paramsModuleName details.moduleName)
|> String.replace "{{routeModuleName}}" (routeModuleName details.moduleName)
|> String.replace "{{pagesPageImports}}" (pagesPageImports details.files)
|> String.replace "{{pagesFolderRouteImports}}" (pagesFolderImports "Route" details.folders)
|> String.replace "{{pagesFolderPagesImports}}" (pagesFolderImports "Pages" details.folders)
|> String.replace "{{pagesModelTypes}}" (pagesCustomTypes "Model" details)
|> String.replace "{{pagesMsgTypes}}" (pagesCustomTypes "Msg" details)
|> String.replace "{{pagesRecipesTypeAliases}}" (pagesRecipesTypeAliases details)
|> String.replace "{{pagesRecipesFunctions}}" (pagesRecipesFunctions details)
|> String.replace "{{pagesInitFunction}}" (pagesInitFunction details)
|> String.replace "{{pagesUpdateFunction}}" (pagesUpdateFunction details)
|> String.replace "{{pagesBundleFunction}}" (pagesBundleFunction details)
|> String.trim
-- ROUTES -- ROUTES