|
Project Information
Members
Featured
Downloads
Links
|
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 <minhee@dahlia.kr>" name="Author" />
</head>
<body>
<h1>Dirty</h1>
<p>Dirty is a simple DSEL template library that...</p>
</body>
</html>Features
FAQHow 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 |