comment
We are happy to announce the release of WebSharper 4.5!
Install templates for .NET Core SDK: dotnet new -i WebSharper.Templates::4.5.0.265
Download templates for Visual Studio 2017: http://websharper.com/installers/WebSharper.4.5.0.265.vsix
The main highlight is a simplification of the HTML construction functions: div, span, p, etc. Until now, these functions returned type Elt, a subtype of the more general Doc. This often required upcasts to Doc, for example:
1 2 3 4
if someCondition then
Doc.Empty
else
div [] [text "test"] :> DocThese functions now return type Doc, which means that the above can now be written as:
1 2 3 4
if someCondition then
Doc.Empty
else
div [] [text "test"]If you do need to use the Elt API on an element, such as .Dom to retrieve the underlying DOM element, you can create it with eg. Elt.div, which returns Elt like div used to.
Full change list:
WebSharper
Features
- #1001: Strongly-name the .NET Standard core libraries.
- #1002: Added
--jsoutputand--minjsoutputcommand line options, as well asWebSharperJsOutputandWebSharperMinJsOutputproject properties, as equivalents tojsOutputandminJsOutputwsconfig.jsonoptions.
Fixes
- #1000: Compiling in
BundleOnlymode correctly detects compile errors.
WebSharper UI
Features and breaking changes
#183: F# In order to minimize the number of upcasts needed in user code, the following functions now return values of type
Docinstead ofElt:- Functions in the module
WebSharper.UI.Html, such asdiv,span, etc. - Functions in the module
WebSharper.UI.Html.Tags, such asoption,object, etc. - Functions in the module
WebSharper.UI.Html.SvgElements, such asg,rect, etc. Functions in the module
WebSharper.UI.Client.Doc, such asInput,Button, etc.For users who do need values of type
Elt, the following were added:- A new module
WebSharper.UI.Html.Elt, containingElt-returning equivalents to the functions inWebSharper.UI.HtmlandWebSharper.UI.Html.Tags. - A new module
WebSharper.UI.Html.SvgElements.Elt, containingElt-returning equivalents to the functions inWebSharper.UI.Html.SvgElements. - A new module
WebSharper.UI.Client.Elt, containingElt-returning equivalents to the functions inWebSharper.UI.Client.Doc.
- Functions in the module
Fixes
- #112: Pass the correct
Dom.Elementas argument to an.OnAfterRender()called on a template's.Elt(). - #185: Fix setting the class of an SVG element.
Happy coding!






