Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

orfon/reinhardt

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

175 Commits
175 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.