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?
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.