2025-03-17 10:47:11 +01:00

2.4 KiB

flummpress


flummpress / Tpl

Class: Tpl

Defined in: template.ts:4

Constructors

new Tpl()

new Tpl(): Template

Defined in: template.ts:11

Returns

Template

Methods

escape()

escape(str): string

Defined in: template.ts:147

Escapes a string for safe usage in HTML.

Parameters

str

string

The string to escape.

Returns

string

The escaped string.


forEach()

forEach(o, f): void

Defined in: template.ts:163

Iterates over an object or array and applies a callback function.

Parameters

o

any

The object or array to iterate over.

f

(value, key) => void

The callback function.

Returns

void


getMtime()

getMtime(file): number

Defined in: template.ts:180

Retrieves the last modification time of a file.

Parameters

file

string

The file path to check.

Returns

number

The last modification time in milliseconds.


render()

render(file, data, locals): string

Defined in: template.ts:103

Renders a template with the provided data and local variables.

Parameters

file

string

The name of the template file (without extension).

data

Record<string, any> = {}

Data object to inject into the template.

locals

Record<string, any> = {}

Local variables to be used within the template.

Returns

string

The rendered HTML string.


setCache()

setCache(cache): void

Defined in: template.ts:48

Enables or disables the template caching mechanism.

Parameters

cache

boolean

If true, enables caching.

Returns

void


setDebug()

setDebug(debug): void

Defined in: template.ts:23

Enables or disables debug mode.

Parameters

debug

boolean

If true, enables debug mode.

Returns

void


setGlobals()

setGlobals(globals): void

Defined in: template.ts:40

Sets global variables to be used in all templates.

Parameters

globals

Record<string, any>

An object containing global variables.

Returns

void


setViews()

setViews(views): void

Defined in: template.ts:31

Sets the directory for template files and preloads all templates.

Parameters

views

string

The directory path for template files.

Returns

void