Skip to content

Commit

Permalink
TOC and minor cleanup in README
Browse files Browse the repository at this point in the history
  • Loading branch information
oberhamsi committed Jul 18, 2013
1 parent ef49e14 commit d5813a5
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 53 deletions.
58 changes: 8 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ Reinhard already implements the larger part of the Django templating system:
* customize and extend - writing tags and filters
* tons of unit tests - our unit tests are copied straight from django

Goals
============
* aims to be functionally equivalent to the current django master
* not intended to work in a browser environment
* beta software

Small example
===============

Demonstration of a small Reinhardt template:

{% extends 'base.html' %}
{% block title %}Reinhardt's Site{% endblock %}
{% block content %}
Expand All @@ -29,54 +26,15 @@ Small example
</ul>
{% endblock %}

Quickstart Guide
===================

Install reinhardt with Ringo's admin command:

$ ringo-admin install oberhamsi/reinhardt

The most basic way to render a template is to instantiate it from a string:

>> var template = new Template('Hello {{ username}}');
>> template.render({username: 'Reinhardt'});
'Hello Reinhardt'

A templating `Environment` allows you to configure additional tags and filters,
which will be available in all templates loaded through the environment. You will
typically use an Environment for anything but very simple applications:

>> var env = new Environment({
loader: module.resolve('./templates/'),
filters: require('./mycustomfilters')

});
>> env.renderResponse("index.html", context)
{"status": 200, body: ["<html>..."]}

Debugging templates
---------------------

Enable debugging in the environment and put the reinhardt middleware into your application:

>> app.configure(require('reinhardt/middleware'));
>> var env = new Environment({
debug: true
});
Documentation
=========================

Debugging is disabled by default and you should not enable it in production since it displays
the source and location of your templates.
* [Quickstart guide](docs/quickstart.md)
* [Reinhardt template language overview](docs/templates.md)
* References for the built in [Tags](docs/tags.md) [Filters](docs/filters.md)

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.

Documentation
=========================

* [Reinhardt template language overview](docs/templates.md)
* References:
* [Tags](docs/tags.md)
* [Filters](docs/filters.md)

7 changes: 7 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ Contributing

When porting from Django: do not worry about "future" and backwards compatibility. We will deal with that once we hit 1.0.

Goals
============
* aims to be functionally equivalent to the current django master
* not intended to work in a browser environment
* beta software


Implemented filters and tags
=================================

Expand Down
42 changes: 42 additions & 0 deletions docs/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,48 @@ Built-in template filters

This document describes Reinhardt's built-in template filters.

**List of built in filters**

- [add](#add)
- [addslashes](#addslashes)
- [byKey](#bykey)
- [capfirst](#capfirst)
- [center](#center)
- [cut](#cut)
- [date](#date)
- [default](#default)
- [defaultifnull](#defaultifnull)
- [escape](#escape)
- [first](#first)
- [fix_ampersands](#fix_ampersands)
- [floatformat](#floatformat)
- [force_escape](#force_escape)
- [join](#join)
- [last](#last)
- [length](#length)
- [length_is](#length_is)
- [linebreaks](#linebreaks)
- [linebreaksbr](#linebreaksbr)
- [linenumbers](#linenumbers)
- [ljust](#ljust)
- [lower](#lower)
- [make_list](#make_list)
- [removetags](#removetags)
- [rjust](#rjust)
- [safe](#safe)
- [slice](#slice)
- [slugify](#slugify)
- [sortByKey](#sortbykey)
- [striptags](#striptags)
- [title](#title)
- [truncatechars](#truncatechars)
- [truncatewords](#truncatewords)
- [truncatewords_html](#truncatewords_html)
- [upper](#upper)
- [wordcount](#wordcount)
- [wordwrap](#wordwrap)
- [yesno](#yesno)

add
------

Expand Down
16 changes: 16 additions & 0 deletions docs/if-details.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
"if" tag details
===================

This document describes the operator details of the if tag.

**Table of Contents**

- [Boolean operators](#boolean-operators)
- [== operator](#-operator)
- [!= operator](#-operator-1)
- [< operator](#-operator-2)
- [> operator](#-operator-3)
- [<= operator](#-operator-4)
- [>= operator](#-operator-5)
- [in operator](#in-operator)
- [not in operator](#not-in-operator)
- [Filters](#filters)
- [Complex expressions](#complex-expressions)

Boolean operators
------

Expand Down
37 changes: 37 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Quickstart Guide
===================

Install reinhardt with Ringo's admin command:

$ ringo-admin install oberhamsi/reinhardt

The most basic way to render a template is to instantiate it from a string:

>> var template = new Template('Hello {{ username}}');
>> template.render({username: 'Reinhardt'});
'Hello Reinhardt'

A templating `Environment` allows you to configure additional tags and filters,
which will be available in all templates loaded through the environment. You will
typically use an Environment for anything but very simple applications:

>> var env = new Environment({
loader: module.resolve('./templates/'),
filters: require('./mycustomfilters')

});
>> env.renderResponse("index.html", context)
{"status": 200, body: ["<html>..."]}

Debugging templates
---------------------

Enable debugging in the environment and put the reinhardt middleware into your application:

>> app.configure(require('reinhardt/middleware'));
>> var env = new Environment({
debug: true
});

Debugging is disabled by default and you should not enable it in production since it displays
the source and location of your templates.
22 changes: 22 additions & 0 deletions docs/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@ Built-in template tags

This document describes Reinhardt's built-in template tags.

**List of built in tags**

- [autoescape](#autoescape)
- [block](#block)
- [comment](#comment)
- [cycle](#cycle)
- [extends](#extends)
- [filter](#filter)
- [firstof](#firstof)
- [for](#for)
- [for ... empty](#for--empty)
- [if](#if)
- [ifchanged](#ifchanged)
- [ifequal](#ifequal)
- [ifnotequal](#ifnotequal)
- [include](#include)
- [loadtag / loadfilter](#loadtag--loadfilter)
- [spaceless](#spaceless)
- [verbatim](#verbatim)
- [widthratio](#widthratio)
- [with](#with)

autoescape
-----------

Expand Down
27 changes: 24 additions & 3 deletions docs/templates.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
The Reinhardt template language
============================

This document explains the language syntax of the Reinhardt template system. If
you're looking for a more technical perspective on how it works and how to
extend it, see [templates-api].
This document explains the language syntax of the Reinhardt template system.

The Reinhardt template language is designed to strike a balance between power and
ease. It's designed to feel comfortable to those used to working with HTML. If
you have any exposure to other text-based template languages, such as Smarty
or CheetahTemplate, you should feel right at home with Reinhardt's templates.

**Table of Contents**

- [Templates](#templates)
- [Variables](#variables)
- [Filters](#filters)
- [default](#default)
- [length](#length)
- [striptags](#striptags)
- [Tags](#tags)
- [for](#for)
- [if and else](#if-and-else)
- [block and extends](#block-and-extends)
- [Comments](#comments)
- [Template inheritance](#template-inheritance)
- [Automatic HTML escaping](#automatic-html-escaping)
- [How to turn it off](#how-to-turn-it-off)
- [For individual variables](#for-individual-variables)
- [For template blocks](#for-template-blocks)
- [Notes](#notes)
- [String literals and automatic escaping](#string-literals-and-automatic-escaping)
- [Accessing functions](#accessing-functions)
- [Custom tag and filter libraries](#custom-tag-and-filter-libraries)
- [Custom libraries and template inheritance](#custom-libraries-and-template-inheritance)

Templates
=========
Expand Down

0 comments on commit d5813a5

Please sign in to comment.