Skip to content
Template project for web apps with cross-platform rendering and client-side logic
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets/html
js/src/main/scala/example Routes: Return Option to handle non-matching routes Mar 13, 2018
jvm/src/main/scala/example Layout: Set `defer` attribute on `script` tags Mar 13, 2018
project
shared/src/main/scala/example Routes: Return Option to handle non-matching routes Mar 13, 2018
.gitignore
README.md Build: Use sbt-crossproject Jan 31, 2018
build.sbt Build: Bump dependencies Mar 10, 2018

README.md

Pine example

This is an example website that uses Pine for HTML rendering, Trail for routing, Circe for JSON handling and http4s for serving pages.

The chosen architecture is:

Server-side rendered pages with client logic and client-side rendering

The initial rendering is performed by the server. Then, the browser only sets up the event handlers. When the page changes, the client renders the page. This is possible since we request the templates from the client and share the rendering logic across the JavaScript and JVM backend. After the initial rendering, no further server requests apart from API requests will be sent. As a consequence, this architecture keeps the website responsive while reducing the server bandwidth.

You can edit templates in assets/html and refresh the page. The server sets up a file watcher that invalidates the template cache upon file changes. As long as the IDs and element types remain the same, templates can be readily changed without the need to restart the server.

Usage

$ sbt
example/reStart

Licence

Pine is licensed under the terms of the Apache v2.0 licence.

Authors

  • Tim Nieradzik
You can’t perform that action at this time.