WebSharper 4.1 (Dec 24, 2017)

  • A unified, declarative framework for server-side (sitelets) and client-side (SPA) routing This will enable using the same syntax for client- and server-side routers+controllers.

    C#:

    Router:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    [JavaScript, EndPoint("/")]
    public class Root
    {
        [EndPoint("/about")]
        public class About : Root
        {
            [EndPoint("/book/{Id}")]
            public class Book : About
            {
                public string Id;
            }
        }
    }

    Controller:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    public class SiteletTest
    {
        public static Sitelet<Root> MySite =
            var router = Router.Infer<Root>;
            router.MakeSitelet((ctx, endpoint) =>
            {
                switch (endpoint)
                {
                    case Root.About.Book b:
                        return Content.Page(div($"About page for Book #{b.Id}"));
                    case Root h:
                        return Content.Page(
                            div(
                                h1("This is the home page"),
                                a("About book #1", attr.href(router.Link(new Root.About.Book() { Id = 1 })))
                            )
                        );
                    default:
                        return Content.NotFound();
                }
            });
    }
  • Enhancements to reactive templating - encapsulated data models, client-side event handlers in sitelets

By on 12/25/2017 3:28 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us
Built with WebSharper