Erik Oosterwaal
Erik Oosterwaal

Reputation: 4384

Web helpers in Python

I am starting a web project in Python, most likely using Django or Pyramid. I have done some work in ASP.NET MVC and I was wondering if Python (or any of the templating engines) have a concept like 'web helpers'?

For those that don't know what that is, it's a callable piece of server-side code that will generate a bit (or even a lot) of HTML.

For example a module I can call server-side (in Python) and fill with data, set some properties (like number of pages in this example) and have it generate a pageable, sortable table in HTML. ASP.NET MVC has a 'webgrid' for this purpose, but it's also sometimes called a 'datagrid' or a 'listview' : http://blog.bekijkhet.com/2011/03/mvc3-webgrid-html-helper-paging.html

I was wondering if Python (or any of the templating engines) has something similar, or if I would have to write it myself?

Upvotes: 0

Views: 457

Answers (3)

Anthony
Anthony

Reputation: 25536

web2py includes a set of standard and specialized HTML helpers, which can be manipulated via a server-side DOM. For data tables/grids specifically, you can check out SQLTABLE, Crud (particularly, crud.select() and crud.search()), and the brand new SQLFORM.grid and SQLFORM.smartgrid (same as .grid, but for linked tables). The latter two are so new, they are not documented yet, though they will be added to the online book within the next week or so (until then, there's this, and you can get help on the mailing list).

Upvotes: 0

Facundo Casco
Facundo Casco

Reputation: 10605

In Django you have template tags and template filter. You include them in your templates and they return some string or unicode value that would be included in the final document sent to the browser.

Upvotes: 0

Jochen Ritzel
Jochen Ritzel

Reputation: 107666

This is hardly a useful question but here you go: Yes, there is a webhelpers module and the frameworks make your life much easier.

Upvotes: 1

Related Questions