Templating methodology, alter instead of replace

Similar to how VQMod catches calls to static core files, this idea allows for capture and modification of calls to template files.  This idea suggests modifying the template stream instead of an outright file replacement.

For example, let's add a custom entry to the main menu bar along the top of the page:
A) The standard method would direct that a copy of views/box_site_menu be made in your custom theme folder, and the necessary addition made in the static html code.
B) This alternative suggestion is instead to add a mostly empty file in that same position in the custom theme folder.  But, instead of statically duplicating the default.catalog file, this custom file includes the default file.  This importation operation has three main phases, in order:

it is possible to modify the snippet and base variables passed to the template file.  All passed variables simply fall through to the default file inclusion if not altered.  (Not all the variables will be accessible.  Deep logic modifications might require core file alterations)

The default catalog file is included directly, after passing through vqmod.  Thus, any fixes to the default template file as vqmods are maintained in the custom template file output.

After inclusion, the default file output is available for brute-force string manipulation.  Bear in mind, this is not the most efficient thing to do often or intensely.  But, if the output is eventually cached, the buffered output not too great, and/or the modifications light, then this is quite viable for some changes.

Easy to make changes (especially data-only changes)
Identify and markup changes as best suits the situation (scattered manipulations can all reside near one another in the code)
Maintain and develop, comment out manipulations to allow unaltered code to pass
Changes to the default catalog template syntax and structure are carried over between system updates.
VQMods applied to the default catalog files are maintained
Stays within the template folder for transport between servers
Replaces a full-file duplicate with a 6-line file
Only possible for dynamic .inc.php files (views,layouts,pages,etc), not static resources images,css,js,etc)
Local variables sheltered inside stdClass object, which is then destroyed at end of use

$O = new stdClass();

//-----optional VARIABLE MANIPULATION here-----//
//per scenario above, could inject category ahead of those from cart system
$categories = array_merge([...], $categories);

//-----DEFAULT FILE INCLUSION (with any vqmods in place)-----//
include vmod::check(FS_DIR_HTTP_ROOT . WS_DIR_TEMPLATES . 'default.catalog/views/' . basename(__FILE__));
$O->output_buffer = ob_get_clean();

//-----optional STRING MANIPULATIONS on $O->output_buffer here-----//

//-----output and cleanup-----//
echo $O->output_buffer;