'filename as class name in VS 2019 Custom Template

When I create a file directly using VS 2019 Add New Item, having selected a folder arbitrarily the path has this pattern: /firstfolder/secondfolder. In the codebehind file Add New Item uses the file path and generates the classname as firstfolder_secondfolder_filename, the inherits attribute is generated as firstfolder_secondfolder_filename, and the code file attribute is generated as filename.aspx.vb

A custom template loses the path structure even when VS variables are included.

this: $eft_safeitemname$ generates Partial Class $ext_safeitemrootname$

this: $safeprojectname$_$safeitemname$ generates
Inherits="$safeprojectname$_CMS_Page4" the CMS_Page4 part is correct but VS is treating the first variable as an actual string, not as a variable.

How do I get the dynamic class name - based on the path - and inherits attribute with a custom Add New Item template?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source