Subscribe to our list to receive the latest updates on Node on Fire

Class: Templates

Templates

new Templates(app)

The templates module loads all templates from the /templates directory in the app's root directory. Plain html files and jade templates are currently supported.

To create a template, store a file in the templates directory in your app's root directory. You can also create inline templates on an App instance:

app.template('hello-world', '<h1>Hello, world</h1>');

In a view route you can simply use the hello-world template, see Controller#template for more on view routes.

This module also creates App#template, see {@link Templates#template}.

Please note: templates are public.

Parameters:
Name Type Description
app App

The app instance.

Methods

template(name, html)

Either gets the html of template, or sets the template's html with html.

This method allows you to create inline templates instead of creating a new file in the templates/ directory.

Please note that a template should always be considered public. A route is automatically created to the template and there is no access restriction.

Parameters:
Name Type Description
name String

The name of the template.

html String

Sets the html of the template. If not set, returns the template's html.

Returns:

Returns the html of the template.

Type
String

Do you have any questions or comments on this page? Start a discussion below.

comments powered by Disqus
Subscribe to our list to receive the latest updates on Node on Fire