mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-09-11 09:05:28 +03:00
Update content.
This commit is contained in:
parent
c4cf9e2430
commit
745b2aa812
@ -96,3 +96,23 @@ Some key points about the no-webpack build:
|
|||||||
-> Head.Tag pathKey
|
-> Head.Tag pathKey
|
||||||
|
|
||||||
## 3 - Beta Template Modules feature
|
## 3 - Beta Template Modules feature
|
||||||
|
|
||||||
|
Pre conditions to using template modules
|
||||||
|
|
||||||
|
- Instead of using `Pages.Platform.init` directly, start building your app with `TemplateModulesBeta.mainTemplate`, see an example here: https://github.com/dillonkearns/elm-pages/blob/3aa978578b152ea74352d97e7b362cecc4da09a4/examples/docs/src/Main.elm#L61
|
||||||
|
- You must have a module called `Shared.elm`, like this example: https://github.com/dillonkearns/elm-pages/blob/dfa71340a21f4d07e835d240b09ab3d990c05f7a/examples/docs/src/`Shared.elm`. That module must expose a `template` value. You must also expose the following types from `Shared`:
|
||||||
|
- `RenderedBody` -
|
||||||
|
- `SharedMsg` - a union of all the Msg's that can be sent from a Template Module and handled by `Shared` to update the shared state.
|
||||||
|
- `Msg` - the Shared Msg type for events that can happen and be received by the Shared module.
|
||||||
|
- `Model` - the Shared module, which can also be accessed by Template Modules if the wire that in with the `Template.elm` builder functions to access that state.
|
||||||
|
- You must have a module called `TemplateType`, which exposes a custom type called `TemplateType.TemplateType`, with a variant for each of your Template Modules (files in the `src/Template` folder) with a corresponding variant name. The variant must have exactly 1 argument, which is the metadata type for that Template. See this example: https://github.com/dillonkearns/elm-pages/blob/dd3f824e4e4aab38cb5633909061418338ee0392/examples/docs/src/TemplateType.elm#L6
|
||||||
|
- You must have at least 1 template module (see Generating a Template Module).
|
||||||
|
|
||||||
|
### Generating a Template Module
|
||||||
|
|
||||||
|
Template modules live in the `src/Template` directory.
|
||||||
|
|
||||||
|
- You can add a new Template Module using `elm-pages-generate Recipe`
|
||||||
|
- The `gen/Template.elm` module provides a builder-style API for each Template. You can add complexity as needed, starting from the generated starting point.
|
||||||
|
- Each module must expose a value called `template`, and a type called `Msg` and `Model` (they can be `()` and `Never` if you don't use them, as in the scaffolded code).
|
||||||
|
- You can see the Elm docs for the generated `gen/Template.elm` module if you install elm-doc-preveiw (`npm i -g elm-doc-preview`), copy [this file](https://github.com/dillonkearns/elm-pages/blob/7fbcfb60d8b7a6422cc34667979bb09084c01a3f/examples/docs/elm-application.json) to your project, and run `elm-doc-preview` from the top-level folder.
|
||||||
|
Loading…
Reference in New Issue
Block a user