Skip to content

A resource selector extension for the Serverful core

License

Notifications You must be signed in to change notification settings

ServerfulArch/Views

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverful/Views

An extension for selecting cached views.

Features

  • View selection, render and request end.
  • A reloadable view cache.
  • Automatic header inserts on load.
  • Predefined handler configurations.

Links

Installation

npm install @serverful/views

const Views = require("@serverful/views");
// ...

Usage

Register the plugin and configure the view directory.

Serverful.Extension(Views(Content, Headers?));

Insertion of predefined headers.

// Headers/Navbar.html
<div>
    <a href="#">Home</a>
    <a href="#">Github</a>
</div>

// Views/Index.html
<serverful navbar>

Handle a request using by selecting a view.

MyServer.Incoming(Packet => {
    // Information processing...
    Packet.Request.View("/internal/embed");
});

This module is licensed under Apache 2.0.