18

Tundra: My comprehensive template engine for Nodejs

 4 years ago
source link: https://github.com/Usbac/tundra
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

The comprehensive template engine for Nodejs.

Tundra is a small, fast and customizable template engine for Nodejs. It perfectly integrates with any back-end framework or technology.

Features

  • Easy to learn and with a small codebase.

  • Cache system for speeding up the loading of views.

  • Customizable syntax.

  • Standard library with useful functions.

  • Inheritance capabilities

  • And more...

Code snippets

{{ print_variable }}

{! print_variable_without_escaping_it !}

{# comment #}

{% var code_inside_this_tags = true %}

~{{ escape_template_tags }}

@require(imported_view.html)

@extends(parent_view.html)

{[ block name ]}
    {[ parent block_name ]}
{[ endblock ]}

Example

Rendering a simple view

Main file:

var http = require('http');
var Tundra = require('tundrajs');
var view = new Tundra();

http.createServer((req, res) => {
    var data = {
        title: 'Tundra',
        msg: 'Hello World!'
    };

    view.render(res, 'home.html', data);

}).listen(8080);

View:

<!DOCTYPE html>
    <head>
        <title>{{ title }}</title>
    </head>
    <body>
        {{ msg }}
    </body>
</html>

Contributing

Any contribution or support to this project in the form of a pull request or message will be highly appreciated.

Don't be shy :)

License

Tundra is open-source software licensed under the MIT license .


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK