No, the templating uses an erasing type provider, so the provided types are not available from outside the assembly.

Of course you can always do something like this:

1
2
3
type NavBarTemplate = Template<"navbar.html">

let NavBar content = NavBarTemplate.Doc(Content = content)

but I understand that it's a bit of boilerplate. Making a generative type provider would fix this, but I think we have other, higher priority improvements we want to make to the templating system. PRs are always welcome though :)

By on 12/5/2016 12:51 PM ()

Hi Loïc, thanks for the information!

Of course you can always do something like this:

type NavBarTemplate = Template<"navbar.html">

let NavBar content = NavBarTemplate.Doc(Content = content)

Do you mean adding the code in the library containing navbar.html and using the NavBar function from another library? It doesn't seem to work neither.

By on 12/5/2016 2:27 PM ()

The function definitely should work. What happens?

By on 12/6/2016 7:01 AM ()

I have the following in LibraryA

1
2
3
4
5
6
type TestTemplate = Templating.Template<"template.html">

[<JavaScript>]
module Test =
    
    let main() = TestTemplate.Doc()

And from LibraryB trying to do this:

1
2
3
4
5
let page() =
  div 
    [
      LibraryA.Test.main()
    ]

But when building LibraryB, I get a compile error:

Could not find file 'C:\Projects\ResourceTestWebSharper\LibraryA\template.html'.

By on 12/6/2016 11:18 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