I am getting the following error:

1
argument #1 is not a literal or a local variable

When trying to add client side on a server Content.Page with the client <@ @> quotation notation.

I kind of guess that it comes from the quotation and is due to the limitation of quotation but was wondering if you guys knew somewhere where I could find more information on the restrictions regarding what I can actually put in?

For example, the following code will crash on renderDoc:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[<JavaScript>]        
module Layout =
    
    type PageLayout =
        { Route: string
          Title: string }

    let render page =
        div [ text page.Title ]

[<JavaScript>]
module Meta =
    open Layout

    type PageMeta = 
        { Title: string }

    let createLayout (meta:PageMeta) =
        { Route = ""; Title = meta.Title }
        

module Server =
    open Layout
    open Meta

    let renderDoc (meta: PageMeta) =
        client <@ createLayout meta |> Layout.render @>

with the following exception:

1
2
3
Additional information: Wrong format for InlineControl at
C:\Users\hudson.IFBUDS02\Server\var\jobs\websharper.ui.next\workspace\WebSharper.UI.Next\Doc.fs: 331.58-331.79: 
argument #1 is not a literal or a local variable

After making the functions local, it still crashes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Server =
    
    type PageLayout =
        { Route: string
          Title: string }
          
    [<JavaScript>]
    let render page =
        div [ text page.Title ]

    type PageMeta = 
        { Title: string }
        
    [<JavaScript>]
    let createLayout (meta:PageMeta) =
        { Route = ""; Title = meta.Title }

    let renderDoc (meta: PageMeta) =
        client <@ render <| createLayout meta @>
  • Lamk

    Seems like this is working:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    
    [<JavaScript>]        
    module Layout =
        
        type PageLayout =
            { Route: string
              Title: string }
    
        let render page =
            div [ text page.Title ]
    
    [<JavaScript>]
    module Meta =
        open Layout
    
        type PageMeta = 
            { Title: string }
    
        let createLayout (meta:PageMeta) =
            { Route = ""; Title = meta.Title }
            
    module Server =
        open Layout
        open Meta
    
        [<JavaScript>]
        let render meta =
            Layout.render <| Meta.createLayout meta
    
        let renderDoc (meta: PageMeta) =
            client <@ render meta @>
    • loic.denuziere

      Yes, the contents of the quotation must be a simple call to a top-level function whose arguments are literals or local variables. It looks like indeed we are missing some documentation about the client function; but for more info you can check the documentation for its WebSharper.Html counterpart ClientSide here.