Choco Templates for Python
=========================
Choco is a template library written in Python. It provides a familiar, non-XML
syntax which compiles into Python modules for maximum performance. Choco's
syntax and API borrows from the best ideas of many others, including Django
templates, Cheetah, Myghty, and Genshi. Conceptually, Choco is an embedded
Python (i.e. Python Server Page) language, which refines the familiar ideas
of componentized layout and inheritance to produce one of the most
straightforward and flexible models available, while also maintaining close
ties to Python calling and scoping semantics.
Nutshell
========
::
<%inherit file="base.html"/>
<%
rows = [[v for v in range(0,10)] for row in range(0,10)]
%>
<table>
% for row in rows:
${makerow(row)}
% endfor
</table>
<%def name="makerow(row)">
<tr>
% for name in row:
<td>${name}</td>\
% endfor
</tr>
</%def>
UI
============
UI tag is inspired by EmberJs Handlebarjs tempalte.
index.html
----------------
::
This is an UI Page
<%@ PostView(post_id)/>
ui/post.html
----------------
::
This is a Post View
Name: ${post.title}
Content: ${post.content}
.. code:: python
def create_ui_container():
from choco.ui import UIContainer, UIModule
ui_container = UIContainer(["template/ui"])
class PostView(UIModule):
default_template = "post.html"
def initialize(self):
self.thing = Thing("Post")
def render(self, post_id):
post = self.thing.getByPostId(post_id)
return {
"post": post
}
ui_container.put_ui("PostView", PostView)
return ui_container
tl2 = lookup.TemplateLookup(directories=["template"], ui_container=create_ui_container())
t12.get_template("index.html").render(post_id=122)
Philosophy
===========
Python is a great scripting language. Don't reinvent the wheel...your templates can handle it !
License
========
Choco is licensed under an MIT-style license (see LICENSE).
Other incorporated projects may be licensed under different licenses.
All licenses allow for non-commercial and commercial use.
Metadata
Release files for Choco 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distributions (sdists)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Choco-1.0.5.zip | 254.8 kB | Without provenance | Details for Choco-1.0.5.zip | |
| Choco-1.0.5.tar.gz | 214.5 kB | Without provenance | Details for Choco-1.0.5.tar.gz |
Release files / Choco-1.0.5.zip
| Download URL | Choco-1.0.5.zip |
|---|---|
| Size | 254.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc5f4d9eafc202013f0f2821a464a43512b265c2bc923a08e75b0427490e31df
|
|
BLAKE2b-256 checksum How to use checksums |
23db2028a7a0e838be7cddb55eed7305d5418c577e854d76a0a0c93c3adcf5fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Choco-1.0.5.tar.gz
| Download URL | Choco-1.0.5.tar.gz |
|---|---|
| Size | 214.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a51b7f9f7bb91c3925135ec4b973201a05a72da2d5cac068a13720391c8b08ae
|
|
BLAKE2b-256 checksum How to use checksums |
9841c270306772b9459020b44eca26d995903919b3488f096950460ff7fd58d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Choco 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.