Introduced a new type of hooks to post-process HTML

#5 Declined
  1. Justin Forest

This type of hooks lets developers manipulate page output without requiring the user to edit the template. Templates can be switched quickly without losing breaking important functions (e.g, analytics).

Comments (2)

  1. Oben Sonne repo owner

    I see your point that the normal post hooks have no access to the templates' HTML head element in order to conditionally inject script tags. But there is no need to alter Poole's core for this task. Just put some Python expressions or statements inside your template, which does this job. The corresponding Python code has access to a page's HTML code so that it is able to make a proper decision (with reference to your example). Concerning the switching of templates without the need to repeat logic in all templates, simply call one macro function in your head tag which takes care of dynamically adding elements to the head. Then there's only one line which has to be propagated in all templates:

    {{ populate_header() }}

    The function populate_header() inside the file could parse page.html to do whatever you need.

    Does this meet your needs?

  2. Justin Forest author

    Not really.

    The point of my proposition is in lettings hooks modify pages without interfering with the template. This is very handy if parts of hooks are separated as plug-ins (see email). Also, if you use multiple templates, you don't have to modify them all every time (I'll send a patch for per-page templates later). With HTML hooks you can have a collection of templates and functional plug-ins, which would be mutually compatible and would not require users to write custom populate_header functions to glue the hooks together.