My favorites | Sign in
Project Logo
             
Show all Featured downloads:
dirty-1.0.2.tar.gz
Links:
Feeds:
People details
Project owners:
  m...@dahlia.pe.kr

Dirty is a simple EDSL template library that helps you to write some HTML or XML markup with Python. It is inspired by Markaby.

>>> from dirty.html import *
>>> page = xhtml(
...   head(
...     title("Dirty"),
...     meta(name="Author", content="Hong, MinHee <minhee@dahlia.kr>")
...   ),
...   body(
...     h1("Dirty"),
...     p("Dirty is a simple DSEL template library that...")
...   )
... )
>>> print(page)
<!DOCTYPE html PUBLIC
  "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" />
  <head>
    <title>Dirty</title>
    <meta content="Hong, MinHee &lt;minhee@dahlia.kr&gt;" name="Author" />
  </head>
  <body>
    <h1>Dirty</h1>
    <p>Dirty is a simple DSEL template library that...</p>
  </body>
</html>

Features

FAQ

How can I loop?

Use a generator expression.

div(
  h3("Members"),
  ul(li(person.name) for person in members)
)

Isn’t there an if-statement in Dirty?

Use a trinary operator.

p("Gender: ", "Male" if person.gender == "M" else "Female")

Yes, it’s too dirty. So I named it like that.

I want to print raw XML/HTML strings that are generated by other modules e.g. Markdown.

There is dirty.RawString class.

>>> from dirty import RawString
>>> from dirty.html import *
>>> print(div(RawString("<em>Thank you!</em>")))
<div><em>Thank you!</em></div>

How can I use XML namespaces?

Sorry, it is unsupported yet. However, it will be added soon.

How To Install

~ $ wget http://dirty.googlecode.com/files/dirty-1.0.2.tar.gz
~ $ tar xvfz dirty-1.0.2.tar.gz 
~ $ cd dirty-1.0.2
~/dirty-1.0.2 $ python3.0 setup.py install








Hosted by Google Code