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
0
votes
1 answer

How to test if tal:repeat loop on last pass?

I have the following code in a Chameleon template: ${menu.title}
cstrutton
  • 5,667
  • 3
  • 25
  • 32
0
votes
0 answers

Umlauts are not escaped (Chameleon / i18n)

I developed a Pyramid application with Chameleon templates. I use the i18n module of Chameleon to access the gettext based translation mechanism. In my translated .po files I have German umlauts. These umlauts are not escaped somewhere and directly…
Knut
  • 431
  • 4
  • 14
0
votes
1 answer

Using tal:repeat variable in tal:condition, Chameleon

I'm using pyramid with Chameleon and I try to add a class to a link dependent of the page number with tal:condition. When I replace page_number for a string it's working but the code below isn't. So something is wrong with the page_number. Any help…
Jab
  • 821
  • 3
  • 13
  • 26
0
votes
1 answer

Pyramid Chameleon base template orientation

I'm very new at Pyramid, I have used Django in the past, but I can't find a clean explanation of how to use base templating in Pyramid Chameleon templates. I have a very simple .pt file which I want to be my base.pt template it's something like…
PepperoniPizza
  • 8,842
  • 9
  • 58
  • 100
0
votes
3 answers

Escape quotes in Javascript/Chameleon template

I am trying to pass a python dictionary from a chameleon template to a javascript function. But since the dictionary contains single quotes or ' which need to be escaped I get an error in firebug that says : SyntaxError: missing ) after argument…
cisnik
  • 107
  • 10
0
votes
1 answer

Giving translators a hint in Chameleon page templates (cpt)

I use Chameleon Page templates as my templating language and I'd like to give my translators a hint. (In this case because the word "you" can be translated quite differently depending on the context.) I cannot find a technique for it in the…
Niels Bom
  • 8,728
  • 11
  • 46
  • 62
0
votes
1 answer

Python, Pyramid, Chameleon : parse Chameleon template in string

I have a Chameleon template stored as a string. I've got it in this form, because I need to do my own processing first. Following that, I want to parse the template, possibly using 'render to response': render_to_response('templates/foo.pt', …
Liam M
  • 5,306
  • 4
  • 39
  • 55
0
votes
1 answer

Why am I getting a NameError when trying to call my Javascript array in a template?

Here is the view callable for my home page that defines jsdata: @view_config(route_name='home_page', renderer='templates/edit.pt') def home_page(request): if 'form.submitted' in request.params: name= request.params['name'] …
BigBoy1337
  • 4,735
  • 16
  • 70
  • 138
0
votes
1 answer

Chameleon template rendering

I am new to chameleon templates. i paste code snippet .. runtemp.py import os path = os.path.dirname(__file__) from chameleon import PageTemplateLoader templates = PageTemplateLoader(os.path.join(path, "templates")) template =…
Nikhil Rupanawar
  • 4,061
  • 10
  • 35
  • 51
0
votes
1 answer

How to work on internationalization of Pyramid forms?

I have been looking online for localization of error messages and labels of pyramid forms but so far without any luck. I have worked on both pyramid_simpleform and pyramid_deform. Has anyone worked on something similiar. The docs are not much of…
Ranjith Ramachandra
  • 10,399
  • 14
  • 59
  • 96
0
votes
2 answers

Populating form fields using TAL/Chameleon

I'm using Chameleon in Python to render my templates. Let's say I want to populate a form field using POST/GET data: The problem with that is if request.params has no key "foo", I…
Theron Luhn
  • 3,974
  • 4
  • 37
  • 49
-1
votes
1 answer

Unexpected nil when using Chameleon's result to set UIView.backgroundColor

I'm trying to use Chameleon to get analogous colors. The returned array of colors is not nil, each of the 5 elements are also not nil. However the code "tintView.backgroundColor = color" results in "Fatal error: Unexpectedly found nil while…
Carl
  • 43
  • 6
-1
votes
1 answer

Getting builtins.NameError when using a Code block in Chameleon

I expected this snippet to work: It instead fails with: NameError: year - Expression: " python import time;…
tshepang
  • 12,111
  • 21
  • 91
  • 136
1 2 3 4 5 6 7
8