Container
With styles in place, let's get our hands on extracting a shared layout for all future views to come.
Start by adding container
parameter to index
in View
:
View.fs
23:
|
|
and div with id "main" just after the div "header":
View.fs
30: 31: 32: 33: 34: 35: 36: 37: |
|
index
previously was a constant value, but it has now become a function taking container
as parameter.
Let's also extract a common function for creating the WebPart, parametrized with the container itself.
Add to App
module, just before the browse
WebPart following function:
App.fs
10: 11: |
|
We can now define the actual container for the "home" page:
View.fs
7: 8: 9: |
|
For now it will only contain plain "Home" text.
Next, containers for rest of valid routes in our application can be defined in View
module:
View.fs
11: 12: 13: |
|
View.fs
15: 16: 17: |
|
View.fs
19: 20: 21: |
|
Note that both home
and store
are constant values, while browse
and details
are parametrized with genre
and id
respectively.
html
can be now reused for all 4 views:
App.fs
13: 14: 15: 16: 17: |
|
App.fs
19: 20: 21: 22: 23: 24: 25: 26: |
|
Full name: SuaveMusicStore.Path.IntPath
type PrintfFormat<'Printer,'State,'Residue,'Result> =
new : value:string -> PrintfFormat<'Printer,'State,'Residue,'Result>
member Value : string
Full name: Microsoft.FSharp.Core.PrintfFormat<_,_,_,_>
--------------------
type PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple> =
inherit PrintfFormat<'Printer,'State,'Residue,'Result>
new : value:string -> PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>
Full name: Microsoft.FSharp.Core.PrintfFormat<_,_,_,_,_>
--------------------
new : value:string -> PrintfFormat<'Printer,'State,'Residue,'Result>
--------------------
new : value:string -> PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = System.String
Full name: Microsoft.FSharp.Core.string
Full name: Microsoft.FSharp.Core.unit
Full name: SuaveMusicStore.Path.home
from SuaveMusicStore.Path
Full name: SuaveMusicStore.Path.Store.overview
Full name: SuaveMusicStore.Path.Store.browse
Full name: SuaveMusicStore.Path.Store.details
from Suave
Full name: SuaveMusicStore.View.cssLink
Full name: Suave.Html.link
Full name: SuaveMusicStore.View.home
Full name: SuaveMusicStore.View.store
Full name: SuaveMusicStore.View.browse
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
Full name: SuaveMusicStore.View.details
Full name: SuaveMusicStore.View.index
Full name: Suave.Html.html
Full name: Suave.Html.head
Full name: Suave.Html.title
Full name: Suave.Html.body
Full name: Suave.Html.div
Full name: Suave.Html.tag
Full name: Suave.Html.a
from SuaveMusicStore
Full name: Suave.Html.htmlToString
from SuaveMusicStore
from Suave
from Suave
from Suave
from Suave
from Suave
Full name: SuaveMusicStore.App.html
Full name: Suave.Successful.OK
from SuaveMusicStore
Full name: SuaveMusicStore.View.index
Full name: SuaveMusicStore.App.browse
Full name: Suave.Http.request
Full name: SuaveMusicStore.View.browse
Full name: Suave.RequestErrors.BAD_REQUEST
Full name: SuaveMusicStore.App.webPart
Full name: Suave.WebPart.choose
Full name: Suave.Filters.path
Full name: SuaveMusicStore.View.home
Full name: SuaveMusicStore.View.store
Full name: Suave.Filters.pathScan
Full name: SuaveMusicStore.Path.Store.details
Full name: SuaveMusicStore.View.details
Full name: Suave.Filters.pathRegex
from Suave
Full name: Suave.Files.browseHome
Full name: Suave.Web.startWebServer
Full name: Suave.Web.defaultConfig
Show code from this section on GitHub