sirex / django-prototype

Simple application to build interactive HTML based on the Django templating system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django Prototype

Build Status

Django Prototype is a simple application which allows you to harness the power of the Django templating system to produce an interactive HTML site.

The template we load is derived from the url path. For example, http://localhost:8000/example/ will seek to load the template templates/example.html with context specified in prototype.yml file.

Features

Quick start

Install django-prototype:

$ pip install django-prototype

Create your first template at templates/index.html:

<!doctype html>
<html lang=en>
  <head>
    <meta charset=utf-8>
    <title>blah</title>
  </head>
  <body>
    <p>{{ content }}</p>
  </body>
</html>

Create prototype.yml file:

urls:
  /:
    context:
      content: It works!

And done. You can see it in browser by running:

$ prototype

and opening http://localhost:8000/ in your browser.

While prototype command is running, you can edit you templates and changes will be displayed automatically in the browser window.

Static files

All your static files should go to static directory and added to templates using static tag:

{% load static %}

<img src="{% static "img/example.png" %}" alt="just another example" />

In this example, img/example.png will be loaded from static/img/example.png.

Named urls

First you need to define name of your url in prototype.yml:

urls:
  /my/page/:
    name: mypage

And then, you can use it in tamplates:

<a href="{% url 'mypage' %}">My page</a>

Now, even you change urls, they will work as long as name points to the right url.

About

Simple application to build interactive HTML based on the Django templating system.


Languages

Language:Python 78.0%Language:HTML 20.9%Language:CSS 1.1%