Questions tagged [chameleon]

Chameleon is an open-source template engine written in Python. It implements both the Zope Pagetemplate specification (TAL and TALES) and a plain text format.

Chameleon is an open-source XML/HTML template engine written in .

It’s designed to generate the document output of a web application, typically HTML markup or XML.

The language used is , originally a invention (see ), but available here as a standalone library that you can use in any script or application running Python 2.5 and up (including 3.x and pypy). It comes with a set of new features, too.

The template engine compiles templates into Python byte-code and is optimized for speed. For a complex template language, the performance is very good.

Features

  • Fast — templates are compiled to byte-code.
  • Extensible — it's easy to extend a language or create your own!
  • Tested — automated tests guard against regressions.

Official website: http://chameleon.repoze.org/

Tag use

When asking questions about the template language, consider adding (TAL constructs) and / or (METAL macro constructs) as well.

118 questions
53
votes
1 answer

How to create zebra-stripe CSS with TAL?

How can I use Chameleon or Zope Page Templates to easily create CSS zebra striping? I want to add odd and even classes to each row in a table, but using a condition with repeat/name/odd or repeat/name/even looks rather verbose even with a…
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
12
votes
3 answers

Speed comparisons between Chameleon and Jinja2

Has anyone here done any benchmarking of Chameleon versus Jinja2, in respect to performance? I'm more used to the Jinja syntax, since I come from Django, but as Pyramid suggests to use Chameleon, I'm thinking if it would be nice to give it a try -…
diogobaeder
  • 461
  • 5
  • 16
11
votes
3 answers

How to use template inheritance with Chameleon?

I am using latest Pyramid to build a web app. Somehow we have started using Chameleon as the template engine. I have used Mako before and it was extremely simple to create a base template. Is this possible with chameleon as well? I have tried to…
Ranjith Ramachandra
  • 10,399
  • 14
  • 59
  • 96
9
votes
1 answer

Pyramid framework and master templates / master page / partial views

I'm experienced with .NET MVC and wanting to learn a Python framework. I chose Pyramid. .NET MVC has the concept of a master page, views and partial views. A master page would look something like: <%@ Master Language="C#"…
qxn
  • 17,162
  • 3
  • 49
  • 72
6
votes
1 answer

How can my chameleon template accept message flashes from the pyramid framework?

I'm learning pyramid and it seems they are trying to get people to use chameleon instead of mako so I thought I'd give chameleon a chance. I like it so far and I can do basic things in the template such as if and for loops but I'm not sure how to…
Lostsoul
  • 25,013
  • 48
  • 144
  • 239
5
votes
1 answer

Allow raw HTML in Deform form description fields

How would you stop Deform from escaping HTML in field titles or descriptions when rendering? My current best solution is to search/replace the returned rendered HTML string with what I need. Deform by default will escape all HTML characters to HTML…
Oli
  • 1,335
  • 1
  • 9
  • 10
5
votes
1 answer

Python (Pyramid framework) is persisting data between requests and I can't figure out why

I'm getting the following error on the second refresh of a page: DetachedInstanceError: Instance is not bound to a Session; attribute refresh operation cannot proceed DetachedInstanceError: Instance is not bound to a…
Chelsea Urquhart
  • 1,388
  • 1
  • 11
  • 18
5
votes
1 answer

Chameleon templates for javascript files?

I am developing a simple pyramid application where I am using JQuery to do AJAX requests. I have until now had my javascript code within my chameleon templates. Now I want to extract my javascript into another location (e.g. as static resources). My…
Graeme Stuart
  • 5,837
  • 2
  • 26
  • 46
4
votes
1 answer

Pyramid, Chameleon and template rendering

I started a project with the Python web framwork 'Pyramid', using the template engine 'chameleon'. I'm a beginner of this frameworks, but I have to use it for a customer. I follow the steps in order to install the framework, then I started coding,…
4
votes
1 answer

Python Pyramid - Add multiple chameleon base templates

I am using this procedure to use a base template which the other templates can derive from. How can I create multiple base templates?
Sukumar
  • 3,502
  • 3
  • 26
  • 29
4
votes
1 answer

Pyramid and Chameleon ZPT

I'm new to web development and am trying to make a simple webpage in python using Pyramid. I've run into a bit of a snag though when it comes to making template files using Chameleon. What I'm trying to do right now is very simple. The view callable…
dpuzz
  • 41
  • 2
4
votes
2 answers

Python Pyramid & Chameleon templating language escapes html

I can't make sense of chameleon's tags. I'm a django user, but decided to introduce my CompSci course mates and myself to Pyramid, since I though more lightweight = easier to learn. At the moment the ${} tag is escaping any html tags I'm trying to…
rdrey
  • 9,379
  • 4
  • 40
  • 52
4
votes
1 answer

How do I conditionally add a class to a block item inside a repeat loop with Chameleon

I am just getting started with pyramid and chameleon templates. I have the following code example that renders a site menu.
  • ${menu.title}
  • cstrutton
    • 5,667
    • 3
    • 25
    • 32
    3
    votes
    1 answer

    using base layout templates in chameleon

    In the pyramid docs there is a nice tutorial on UX stuff here: http://docs.pylonsproject.org/projects/pyramid_tutorials/en/latest/humans/creatingux/step07/index.html One thing I noticed though is in the tutorial they are setting up and passing…
    lostdorje
    • 6,150
    • 9
    • 44
    • 86
    3
    votes
    1 answer

    ajax widgets in pyramid and chameleon

    I would like to be able to easily create ajax 'widgets' backed by chameleon and pyramid on the server side. Does Pyramid provide any plumbing code that would make writing widgets easy? My current approach is I have a home view which uses home.pt as…
    lostdorje
    • 6,150
    • 9
    • 44
    • 86
    1
    2 3 4 5 6 7 8