JCC Express

Views

Introduction

Server-side views are HTML templates rendered during a request. JCC Express MVC uses JCC Blade, a Blade-inspired engine that compiles Laravel-style syntax to HTML on the server (see JCC-Blade.md for directives, internals, and custom extensions). Templates live under your configured views directory (typically resources/views) with the configured file extension (often .blade.html).

Configuration is merged into the application config as engine (see app/Config/engine.ts and app/Config/index.ts). The framework’s Middleware class registers Express’s app.engine, app.set("views", …), and app.set("view engine", …) from that config when the HTTP app boots.

For Inertia (React/Vue pages instead of Blade HTML), see Getting-Started/Frontend.md and Response.md. Many apps use Blade for some routes and Inertia for others.


Configuration

Default shape (your project may adjust paths or the render binding):

TypeScript
  • view — Directory relative to the application root where templates are resolved.
  • viewEngine — Function Express calls to render a template by path.
  • viewEngineExtension — Extension passed to Express (omit it when naming views in code; see below).

The EngineConfig type lives in jcc-express-mvc/lib/Type.


Rendering a view

Dot paths, no extension — Express resolves users/index to a file under the views root, using the configured engine extension (e.g. resources/views/users/index.blade.html).

TypeScript

Same behavior with the global helper (see Response.md):

TypeScript

Route shorthand — Route.view(uri, viewName, data?) registers a GET route that calls res.render:

TypeScript

Data and res.locals

The second argument to render / view becomes template data. In addition, res.locals is merged into what the engine sees. The framework already sets useful keys when middleware runs—for example validation errors and old input after failed validation, and _token for CSRF when csrf() is active (Request.md, CSRF-protection.md).

Use res.locals in middleware or controllers when every view should see a value without passing it on every render call.


Syntax overview (JCC Blade)

See JCC-Blade.md in this folder for the full directive list, render pipeline, performance notes, whitelisted [object Object] methods, and custom registerDirective usage. The engine’s in-repo README (jcc-express-mvc/lib/Templating-engine/README.md) holds the benchmark command and implementation-focused notes.


Where files live

See Getting-Started/Directory-structure.md: views under resources/views/ (or your engine.view path), static assets under public/, and Vite sources under resources/ when you use @vite or Inertia.


Summary

  • Wire the engine in app/Config/engine.ts; Express views and view engine are set at boot.
  • Render with res.render / view() or Route.view; merge data with res.locals as needed.
  • Blade syntax and engine details: JCC-Blade.md; package README under jcc-express-mvc/lib/Templating-engine/README.md.
  • Vite and built assets in templates: Asset-bundling.md.