0
comment
comment
on 12/15/2015 2:56 AM
We are happy to announce the release of WebSharper 3.6.6. Here are the main highlights.
Cookies library
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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")Require resources in server-side markup
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.
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 31 32 33 34 35
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
- #491: Remove reference from
WebSharper.Sitelets.dlltoWebSharper.Compiler.dll - #498: Add
WebSharper.Web.Require(see above). - #502: Add client-side Cookies library (see above).
- #503:
Windowinherits fromEventTarget, allowing the use ofAddEventHandleronJS.Window. - #504: MSBuild task: force loading the right version of FSharp.Core in the appdomain.
- #506: In unpack task, use
$(OutDir)if set. - #507: Honor optional arguments
Async.AwaitEvent(?cancelAction)andAsync.StartChild(?timeout). - #508: bind multiple-argument versions of
JSON.Stringify. - #509: Fix
JSON.Serializemacro for recursive types. - Add missing proxies for
querySelectorandquerySelectorAllonWindowandDom.Element. - Add proxy for
System.TimeoutException. - Always extract resources when
WebSharperProjectisSite, thus fixing WebSharper.Suave #7.
WebSharper.UI.Next
- #60: Templating: allow using the same simple text hole in multiple places.
- #65: Make sure to set the selected element after rendering the select box.
Happy coding!






