tits

TITS is a recursive acronym for "TITS is Templating System"

npm install tits
2 downloads in the last week
8 downloads in the last month

TITS is Templating System

TITS is a service for running various Javascript templates through the use of adapters. It supports multiple namespaces (template collections).

TITS is a server built on NodeJS that runs on Linux and OS X. The server process listens on port 60065 by default. Clients (eg. PHP) connect to the TITS process through the driver and perform a sequence of fetch operations.

Installing

npm install -g tits

Getting Started

First you should know about TITS configuration file. You have to provide such file when you start TITS process.

Configuration file

See examples/fest/tits.json. TITS takes the following parameters:

{
    "path" : "./data",          // path to store compiled template collections (this is the default value)
    "watcher": true,            // file watcher (defaults to false)
    // "debug": true,           // if a render error occurs, error message is returned as rendering result (this is the default value)
    // "mode" : 0711,           // default file mode (this is the default value)
    // "port" : 60065,          // server process port number (this is the default value)
    // "statPort" : 60066,      // server process port number for statistics (this is the default value)
    // "shutdownTimeout": 5000, // timeout for graceful shutdown and restart (this is the default value)
    "workers": 1,               // number of server workers (defaults to null - equal to the number of CPU cores)
    // "pid": null,             // path to the PID file (this is the default value)
    "adapters": [{
        "extension": "xml",               // file extension is used to determine the adapter
        "name": "fest",                   // name of the adapter
        "main": "../../adapters/fest.js", // path to the adapter module
        "options": {                      // adaptor-specific compiler options
            "debug": true,
            "nothrow": false,
            "beautify": true
        }
    }],
    "namespaces": [{
        "name": "example",        // name of the template collection
        "path": "./templates",    // path to the directory with templates
        "context": "./context.js" // path to the namespace context module
        "public": {               // publicly available templates (optional)
            "path": "./www", // path to store compiled templates (somewhere in the publicly available folder)
            "format": "amd", // output format (support 'amd' and 'raw')
            "files": [       // subset of the template collection
                "*"
            ]
        }
    }]
}

You want to validate your configuration file.

Run tits without options. It will print out the configuration.

tits examples/fest/tits.json

You are in development environment and want to start the service with enabled file watcher.

You have to set watcher parameter in the configuration file. And start tits with the following arguments.

tits --compile --server examples/fest/tits.json

It will build namespaces (option --compile) and start the server process. On file changes the server will rebuild namespaces and restart workers.

Production.

You have to build namespaces (compile template collections) first.

tits --compile examples/fest/tits.json

You have to disable the file watcher in configuration file and start tits:

tits --server examples/fest/tits.json

Note it's not necessarily to have the template sources in production.

npm loves you