The Pyramid Mako template introduces a step method for helper objects

  • 2020-04-02 13:15:50
  • OfStack

The idea is that we insert our helper in the before render event of pyramind

1. Create a helper.py file and add the usual methods to it

2. In the file of s/s. Py:

Add this function:


def add_renderer_globals(event): 
    event['h'] = helpers


In the main function

config.add_subscriber(add_renderer_globals, BeforeRender)


3. Use the defined method in the template, h. thod()


Related articles: