Skip to content

Latest commit

 

History

History
125 lines (102 loc) · 6.97 KB

ProjectTemplates.md

File metadata and controls

125 lines (102 loc) · 6.97 KB

Main Application Templates

The three main WebSharper application types are:

  1. Client-Server Application - a full client-server application implemented as a WebSharper sitelet.

    The sitelet uses a dynamic HTML template and placeholders that are instantiated by the sitelet. See the HTML templates page for more information on dynamic templating.

    These applications exist in two kinds: a Client-Server Web Application runs as an ASP.NET module, while a Self-Hosted Client-Server Web Application runs as a self-contained executable using an OWIN self-host container.

  2. HTML Application - a multi-page HTML/JavaScript application.

    Like the Client-Server Application, this application also uses sitelets and dynamic HTML templates to define web pages. However, it creates a set of static HTML and JavaScript files that can be deployed in any HTML container.

    WebSharper mobile web applications can also be created from this template.

  3. Single-Page Application - a single-page HTML/JavaScript application with an HTML page and an F# source file that plugs content into it.

    The easiest way to get started with WebSharper: write a few lines of F#, add a placeholder for it in the HTML, and you are ready to go.

    See the "Your first app in 2 minutes" tab for an example.

The following helper projects are also available:

  1. Library - a simple WebSharper library. Annotated code is compiled to JavaScript, and can then be used from any application project.

  2. Extension - defines the interface to an existing JavaScript library using a convenient declarative F# syntax.

Capabilities

This table summarizes the capabilities of the available application/helper project templates:

Template All-F# Is Sitelet? Client Server Remote
Applications
Client-Server App
ASP.NET-based or self-hosted via OWIN
X X X X X
HTML App X X X X
Single-Page App X X X
Helpers
Library X X X X
Extension X X X
ASP.NET Container X
  • Client - Contains code compiled to JavaScript, executing on the client-side.

  • Server - Contains code you deploy for your application, executing on your server-side.

  • Remote - Contains code you from someone else's server, typically through a web service.

MSBuild / XBuild Project File Configuration

WebSharper project files must include the file WebSharper.targets, which defines the necessary compilation tasks. The type of project is driven by the property WebSharperProject. Here are the possible values:

  • Site: for Client-Server Applications.
    • Compiles JavaScript-annotated code;
    • Extracts resources in the folders Content/WebSharper and Scripts/WebSharper.
  • Html: for HTML Applications.
    • Compiles JavaScript-annotated code;
    • Generates HTML files in $(WebSharperHtmlDirectory) and extracts resources in $(WebSharperHtmlDirectory)/Content/WebSharper and $(WebSharperHtmlDirectory)/Scripts/WebSharper.
  • Bundle: for Single-Page Applications.
    • Compiles JavaScript-annotated code;
    • Extracts and concatenates resources into the folder Content.
  • Library: for Libraries.
    • Compiles JavaScript-annotated code.
  • InterfaceGenerator: For Extensions.
    • Compiles the classes defined using WIG into an assembly.

The other MSBuild project variables are fully documented here.