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:
if someCondition then
Doc.Empty
else
div [] [text "test"] :> Doc
These functions now return type Doc
, which means that the above can now be written as:
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:
--jsoutput
and --minjsoutput
command line options, as well as WebSharperJsOutput
and WebSharperMinJsOutput
project properties, as equivalents to jsOutput
and minJsOutput
wsconfig.json
options.BundleOnly
mode correctly detects compile errors.#183: [F#] In order to minimize the number of upcasts needed in user code, the following functions now return values of type Doc
instead of Elt
:
WebSharper.UI.Html
, such as div
, span
, etc.WebSharper.UI.Html.Tags
, such as option
, object
, etc.WebSharper.UI.Html.SvgElements
, such as g
, rect
, etc.WebSharper.UI.Client.Doc
, such as Input
, Button
, etc.For users who do need values of type Elt
, the following were added:
WebSharper.UI.Html.Elt
, containing Elt
-returning equivalents to the functions in WebSharper.UI.Html
and WebSharper.UI.Html.Tags
.WebSharper.UI.Html.SvgElements.Elt
, containing Elt
-returning equivalents to the functions in WebSharper.UI.Html.SvgElements
.WebSharper.UI.Client.Elt
, containing Elt
-returning equivalents to the functions in WebSharper.UI.Client.Doc
.Dom.Element
as argument to an .OnAfterRender()
called on a template's .Elt()
.Happy coding!
Can’t find what you were looking for? Drop us a line.