Sadly the implementation of Sitelets doesn't allow for something that would look like (fn : 'T -> Content<'T> option) -> Sitelet<'T> which would come in handy sometimes indeed (if I understand you correctly you want to do something similar too). Instead you can do something a bit clunkier but essentially the same:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    type Action =
        | Home
        | Login
        | Logout
        | Register

    let Main =
        Sitelet.Sum [
            Sitelet.InferPartial id
                (function
                    | Login -> Some Login
                    | Home -> Some Home
                    | Register -> Some Register
                    | Logout -> None)
                (function
                    | Login -> Content.NotFound
                    | Home -> Content.NotFound
                    | Register -> Content.NotFound
                    | Logout -> failwith "Should never happen.")
            Sitelet.Infer <| function
                | Logout -> Content.Forbidden
                | _ -> failwith "Should never happen."
        ]
By on 2/27/2015 2:00 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper