We are happy to announce the release of WebSharper 4.5.5.
Download the project templates for .NET Core SDK: dotnet new -i WebSharper.Templates::4.5.5.283
Or use the extension for Visual Studio 2017: http://websharper.com/installers/WebSharper.4.5.5.283.vsix
The main highlight of this release is the addition of dynamic templating: the capability to fill template holes using their name as a string, rather than a strongly typed method. This is done using the .With()
method.
open WebSharper.UI.Templating
type MyTemplate = Template<"<div>${SayWhat} ${ToWhom}!</div>">
let helloWorld =
MyTemplate()
.SayWhat("Hello") // Usual strongly typed fill
.With("ToWhom", "world") // New dynamic fill
.Doc()
Accompanying this is a new type DynamicTemplate
which is not a provided type, and therefore can only be filled using .With()
.
open WebSharper.UI.Templating
let helloWorld =
DynamicTemplate("<div>${SayWhat} ${ToWhom}!</div>")
.With("SayWhat", "Hello")
.With("ToWhom", "world")
.Doc()
Note that this feature is only available on the server side for now.
Full release notes:
<ws-*>
template instantiation is now implemented on the server side.Var<string>
holes are fully bound on the client side, including dynamically bound to ${Text}
holes with the same name in the same template..With("holeName", value)
now fills the given hole with the given value. An error is raised at runtime if the type of value
is incompatible with the hole.DynamicTemplate
as a non-provided type similar to the provided Template
, with the following differences:
DynamicTemplate
is (for now) server-side only.DynamicTemplate
must be instantiated with a string argument.DynamicTemplate
holes can only be filled with .With()
.DynamicTemplate
instantiation can only be finished with .Doc()
.dotnet watch
without running into an infinite loop.Happy coding!
Can’t find what you were looking for? Drop us a line.