I'm considering writing an extension that greatly depends on hooks that are available before and during template parsing. I see in the ExpressionEngine hook documentation that there is a hook called 'template_fetch_template' and its parameter is an array of template data called $row. I can't tell from the documentation exactly what data is in that array. What are the array indexes and what kind of content do they possess?
This is array_keys($row):
Array (  => template_id  => site_id  => group_id  => template_name  => save_template_file  => template_type  => template_data  => template_notes  => edit_date  => last_author_id  => cache  => refresh  => no_auth_bounce  => enable_http_auth  => allow_php  => php_parse_location  => hits  => group_name )
template_data is probably the most interesting one. It contains the unparsed template code. Note that you cannot change the template code directly (because $row is a copy not a reference), but you can prepend to the $this->EE->config->_global_vars array with a key that consists of a substring from the template code (or indeed, the entire template code could be the key). As the globals array is replaced into the template later on this gives you a mechanism for manipulating the template code before it is parsed.