https://github.com/jasonrbriggs/proton
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.
https://github.com/jasonrbriggs/proton
haskell java nim python
Last synced: 3 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/jasonrbriggs/proton
- Owner: jasonrbriggs
- License: apache-2.0
- Created: 2013-02-13T23:30:37.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2022-07-10T20:07:53.000Z (over 3 years ago)
- Last Synced: 2025-10-11T09:14:21.157Z (4 months ago)
- Topics: haskell, java, nim, python
- Language: Java
- Size: 270 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
proton
======
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.
A simple Proton template looks like this:
PAGE TITLE
PAGE TITLE
- LIST ITEMS
And to render this template in Python, you might do something like this:
from proton import template
tmp = template.get_template('test.xhtml')
tmp.set_value('title', 'An Xhtml Page', '*')
tmp.set_value('link', 'This is a link to Google')
tmp.set_attribute('link', 'href', 'http://www.google.com')
tmp.repeat('list-item', 5)
for x in range(0, 5):
tmp.set_value('list-item', 'test%s' % x, x)
print(str(tmp))
Resulting in the following output:
An Xhtml Page
An Xhtml Page
- test0
- test1
- test2
- test3
- test4
Similarly in Haskell, you could do the following:
tmps <- loadTemplates "templates"
tmp <- getTemplate tmps "templates/test.xhtml"
tmp <- setElementValue tmp "title" "An Xhtml Page" 0
tmp <- setElementValue tmp "link" "This is a link to Google" 0
tmp <- setAttributeValue tmp "link" "href" "http://www.google.com" 0
tmp <- setElementValues tmp "list-item" (map (\x -> "test" ++ (show x)) [0..4])
s <- renderTemplate tmp