We are happy to announce the release of WebSharper 3.6.6. Here are the main highlights.
We integrated a library to facilitate the management of cookies on the client side. It is available under WebSharper.JavaScript.Cookies
. Here is a small example:
open WebSharper
open WebSharper.JavaScript
[<JavaScript>]
let testCookies() =
// Set a cookie
Cookies.Set("key", "value")
// Set a secure cookie which expires in a day
Cookies.Set("key", "value",
Cookies.Options(
Secure = true,
Expires = System.DateTime.Now.AddDays(1.).JS))
// Get a cookie
let value = Cookies.Get("key")
// Delete a cookie by setting it to expire immediately
Cookies.Expire("key")
It can sometimes be useful to depend on a resource, such as a CSS file, without having any client-side markup. This is now possible using a WebSharper.Web.Require
control.
open WebSharper
// Let's say you have a resource defined:
type MyResource() =
inherit Resources.BaseResource("style.css")
[<assembly: System.Web.UI.WebResource("style.css", "text/css")>]
do ()
// And you want to include it in your page that doesn't contain client-side code.
// Using UI.Next:
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Server
let styledElement() =
div [
text "A page containing this element will include style.css"
Doc.WebControl (Web.Require<MyResource>())
// Or equivalently:
Doc.WebControl (Web.Require(typeof<MyResource>))
]
// Using WebSharper.Html:
open WebSharper.Html.Server
let styledElement() =
Div [
Text "A page containing this element will include style.css"
Web.Require<MyResource>()
// Or equivalently:
Web.Require(typeof<MyResource>)
]
That's it for the main new features; here is the full change log.
WebSharper.Sitelets.dll
to WebSharper.Compiler.dll
WebSharper.Web.Require
(see above).Window
inherits from EventTarget
, allowing the use of AddEventHandler
on JS.Window
.$(OutDir)
if set.Async.AwaitEvent(?cancelAction)
and Async.StartChild(?timeout)
.JSON.Stringify
.JSON.Serialize
macro for recursive types.querySelector
and querySelectorAll
on Window
and Dom.Element
.System.TimeoutException
.WebSharperProject
is Site
, thus fixing WebSharper.Suave #7.Happy coding!
Can’t find what you were looking for? Drop us a line.