Skip to content

Latest commit

 

History

History
45 lines (30 loc) · 1.23 KB

File metadata and controls

45 lines (30 loc) · 1.23 KB

Command Line Interface

Installing nhp makes the nhp executable available to npm scripts and package-manager command shims.

Syntax

nhp <input.nhp> [output.html]

input.nhp is the template to compile. If output.html is omitted, NHP writes an HTML file next to the input using the same basename.

nhp views/index.nhp
# writes views/index.html

nhp views/index.nhp public/index.html
# writes public/index.html

The command creates missing parent directories for the output path. It prints the resolved output path on success and exits with status 1 after writing an error to stderr on failure.

Package scripts

For a project dependency, npm automatically exposes the binary in scripts:

{
  "scripts": {
    "build:html": "nhp src/pages/home.nhp dist/home.html"
  }
}

Run it with:

npm run build:html

Rendering context

The CLI compiles with an empty render context. Use it for templates that contain static content, set values, includes, and other self-contained directives. Values that rely on application locals are undefined unless the template provides a fallback expression.

For dynamic templates, use the Node.js API to supply render locals. See Getting started.