Search code examples
f#websharper

Problems with simple example on WebSharper's official site


I have downloaded and installed the latest version of WebSharper. On this page there is an example, in which one of the lines is as follows:

let HomePage =
    Template "HomePage" <| fun ctx ->
        [ Div [Text "HOME"] Links ctx Div [new Controls.HelloControl()] ]

In Visual Studio 2012 Ultimate RC, the "Web Application (Sitelet)" template already provides the following code:

let HomePage =
    Skin.WithTemplate "HomePage" <| fun ctx ->
        [
            Div [Text "HOME"]
            Links ctx
        ]

When I try to add Div [new Controls.HelloControl ()] after Links ctx Visual Studio redlines Links ctx with the message: This value is not a function and cannot be applied. I have tried changing Skin.WithTemplate to just Template, but then Template itself gets redlined with the message The value or constructor Template is not defined.

Any help in resolving the problem will be greatly appreciated. It would also be helpful to know if the official documentation at the WebSharper web site is generally up-to-date.

Here is a screen shot.

Visual Studio 2012 Ultimate screenshot


Solution

  • let HomePage =
        Skin.WithTemplate "HomePage" <| fun ctx ->
            [
                Div [Text "HOME"]
                Links ctx
                Div  [new Controls.HelloControl ()]
            ]
    

    Notice the line break. F# has a whitespace-significant syntax.