Skip to content

ehoogerbeets/reinhardt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reinhardt - Django templates for RingoJs

This is a JavaScript implementation of the Django Template System as described in http://www.djangoproject.com/documentation/templates/ for RingoJs.

Reinhard already implements the larger part of the Django templating system:

  • all iteration and conditional tags (if/else, loops, etc).
  • most other filters and tags.
  • autoescaping
  • customize and extend. Write your own tags and filters.
  • tons of unit tests. Our unit tests are copied straight from django.

Small example

Demonstration of a small Reinhardt template:

{% extends 'base.html' %}
{% block title %}Reinhardt's Site{% endblock %}
{% block content %}
  <ul>
  {% for user in users %}
    <li><a href="{{ user.url }}">{{ user.username }}</a></li>
  {% endfor %}
  </ul>
{% endblock %}

Documentation

Quickstart

Create a Reinhardt template environment, which loads templates from the filesystem and render a template:

var {Reinhardt} = require('reinhardt');
var templates = new Reinhardt({
  loader: '/path/to/templates/',
  debug: true
});

var template = templates.getTemplate('index.html');
var html = template.render({"hello": "world"});

// or for convinience the template environment
// an return a 200 response with the template as the
// response body
template.renderResponse({"hello": "other world"})

For easier template debugging, add the reinhardt middleware to your Stick application:

app.configure(require('reinhardt'), 'route')

Speed

There is a examples/speed.js which is farily easy to read. On my machine with the use-cases I have, reinhardt is roughly the same speed as the original Django template language.

About

Django templates for RingoJS

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.0%
  • HTML 2.0%