My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads

Proton is a simple, "code-less" engine for xml/xhtml templates. Code-less, because it uses 3 types of ID (attribute) in a template file, rather than snippets of code — this moves the complexity out of the template and into the application.

There are currently implementations available in Python (Py3K) and Java.

A simple Proton template looks like this:

<html>
<head>
<title eid="title">PAGE TITLE</title>
</head>
<body>
    <h1 eid="title">PAGE TITLE</h1>

    <p><a eid="link" aid="link" href="">LINK ITEM</a></p>

    <ul>
        <li rid="list-item" eid="list-item">LIST ITEMS</li>
    </ul>
</body>
</html>

And to render this template, you might do something like this:

tmp = Templates()['test.xhtml']

tmp.setelement('title', 'An Xhtml Page', '*')
tmp.setelement('link', 'This is a link to Google')
tmp.setattribute('link', 'href', 'http://www.google.com')

tmp.repeat('list-item', 5)
for x in range(0, 5):
    tmp.setelement('list-item', 'test%s' % x, x)

print(str(tmp))
Powered by Google Project Hosting