Questions tagged [cheetah]

Cheetah3 is a free and open source (MIT) Python template engine. Works with Python 2.7 and 3.4+.

Where is CheetahTemplate3

Site: https://cheetahtemplate.org/

Download: https://pypi.org/project/CT3/

News and changes: https://cheetahtemplate.org/news.html

Mailing lists: https://sourceforge.net/p/cheetahtemplate/mailman/

Development: https://github.com/CheetahTemplate3

Developer Guide: https://cheetahtemplate.org/dev_guide/

Example

Install:

$ pip install CT3 # (or even "ct3")

Below is a simple example of some Cheetah code, as you can see it's practically Python. You can import, inherit and define methods just like in a regular Python module, since that's what your Cheetah templates are compiled to :) :

#from Cheetah.Template import Template
#extends Template

#set $people = [{'name' : 'Tom', 'mood' : 'Happy'}, {'name' : 'Dick',
                        'mood' : 'Sad'}, {'name' : 'Harry', 'mood' : 'Hairy'}]

<strong>How are you feeling?</strong>
<ul>
    #for $person in $people
        <li>
            $person['name'] is $person['mood']
        </li>
    #end for
</ul>
73 questions
2
votes
3 answers

Is there a way to get a list of all placeholders in a cheetah template

For example, if I have a template such as "SELECT * FROM myOrders WHERE order_id = ${orderId} and order_date = ${orderDate}" I would like to get a list of all placeholders in that template, i.e. ['orderId', 'orderDate']
victtim
  • 790
  • 5
  • 17
2
votes
2 answers

Passing data from the cherrypy server-side to javascript client-side

Big picture question. I've got a cherrypy server running with all the shopping cart methods for my e-commerce site written in python. I'm working with jquery on the front end. POSTing to my python methods is easy in javascript, but not passing data…
colinmarc
  • 21
  • 2
2
votes
2 answers

Cheetah with Cherrypy: how to load base templates, and do so automatically on change during development

I am working on a cherrypy+cheetah app and would like to improve the development experience. I have everything working when I manually compile templates beforehand. (Update: This is how things work for production: precompile, don't ship *.tmpl and…
Heikki Toivonen
  • 30,964
  • 11
  • 42
  • 44
2
votes
4 answers

Installing GNU Radio on ubuntu

Im trying to install GNU Radio, I need this to be able to install gqrx to use my software defined radio dongle. I have followed the guide at https://www.jeroennijhof.nl/wiki/index.php/Software-Defined_Radio_on_Ubuntu but the installation aborts…
Karl
  • 59
  • 1
  • 2
  • 5
2
votes
2 answers

CherryPy can't seem to find CSS script (static or absolute paths)

i'm using the cherryPy framework to serve my site, but it cannot seem to find my css script with either the static path or the absolute path. The css script works fine if i just go to the index.tmpl file via the browser, but when i request it via…
Lex
  • 386
  • 1
  • 4
  • 20
2
votes
0 answers

create a cheetah tool for cherrypy

I just started to play around with cherrypy and wanted to use cheetah as a templating engine. Therefore I wanted to create a tool so I just can use the annotation feature to point to my template something like import cherrypy class Root(object): …
daniel
  • 1,002
  • 13
  • 22
2
votes
0 answers

What would a Cheetah template binding for Pyramid look like?

I've found this topic, which talks about Pystache, and I've seen a few bindings on Github for other engines but I'm confused on how to get Cheetah to work with Pyramid. Any pointers or what the code might look like?
2
votes
1 answer

Easiest and fastest way to template, possibly in a PDF

I have been looking extensively for a simple solution to a not-very-complicated problem. I have a great deal of data in a sql database which needs to be printed (for example, each entry would have name, address, phone number, etc). The vast majority…
floppyraid
  • 145
  • 1
  • 1
  • 9
1
vote
1 answer

Best method to replace iframes from an application

So I am rewriting the UI for an application that currently loads all the actual page content via iframes and just has a wrapper around it that contains a menu and some other information. My question is what is the best method to replace these…
BillPull
  • 6,853
  • 15
  • 60
  • 99
1
vote
1 answer

Jinja variable not being set properly in for loop

I am having a variable scope issue in Jinja that is misaligning a table. I am trying to convert the current template that is written in Cheetah to Jinja but for some reason this block of logic does not translate and getting the output the python is…
BillPull
  • 6,853
  • 15
  • 60
  • 99
1
vote
0 answers

How do we setup Cheetah so it runs with all templates in the templates directory and all code in the .. directory

How do we setup Cheetah so it runs with all templates in the templates directory and all code in the .. directory in code.py production=True if not production: try:web.render('mafbase.tmpl', None, True, 'mafbase') except:pass else: from…
pylabs
  • 31
  • 1
  • 1
  • 6
1
vote
1 answer

calling a function with cherry.py

So im doing a bit of web development, and due to some restriction set by my employer i need to use cheetah and cherrypy. I have this form that upon submit runs a function, and from said function i call another via HTTPRedirect, and what i want is to…
Lex
  • 386
  • 1
  • 4
  • 20
1
vote
1 answer

Cheetah template filters

Sorry if the question sounds naive. I have a cheetah template, e.g: #filter None $none should be '' $number should be '1' #end filter with namespace = {'none': None, 'number': 1} So basically I want to convert all…
BPm
  • 2,924
  • 11
  • 33
  • 51
1
vote
2 answers

Using a variable called 'request' in dictionary with Python Cheetah3

I've been experimenting with Cheetah3 as a templating engine to transform XML into something else. I have this working, using the below example XML input 1
Cynan
  • 160
  • 1
  • 5
1
vote
1 answer

Check if Cheetah Template Dict has key

I am trying to come up with a base template for an application and one of the goals would be to remove any unnecessary js/css from pages so I want to do something in the cheetah template like #if $dict.has_key('datepicker'):
BillPull
  • 6,853
  • 15
  • 60
  • 99