Modifying Generated Code Templates in Delphi 2005

NOTE: This information falls under the use at your own risk category.  During
the Internet Team chat session we recorded the other day the issue of being able
to modify the code that the IDE generates when you create new WebForms came up
and I mentioned that I would blog about it. Well, here is that blog entry. If
you want to change the code that is generated for many of the different file
types that the IDE creates you should look in your Delphi 2005 folder for a subfolder
named ObjRepos which contains all of the template files that the IDE uses to
generate File|New items.

For example, let’s say you have a stylesheet that you always use for your
HTML pages. You could change the template for HTML files to always link to your
stylesheet so that you don’t have to manually add it each time.  Here are the
steps you would follow to make this change:

  1. Open the Delphi 2005\ObjRepos\Markup folder
  2. Find the file HTMLPageTemplage.htm and edit open using your favorite editor
  3. Add a LINK tag to
    the HEAD section of the page template file
  4. Save the changes

That’s it!  You’ve now modified the default page template for HTML files to
always include your own stylesheet.  Pretty sweet huh?  You can do the exact
same thing for many other file types used by the IDE.  Another example is if you
didn’t want the ASP.NET debug settings in your machine.config file you could
change the web.config file under .\objrepos\DelphiDotNet to include the same
debug settings so that every ASP.NET application you create in Delphi will
automatically have those settings (not necessarily a great idea because of
deployment issues). For more information refer to this

I don’t have a table which maps all of the files to there specific file types
so you might have to do a bit of digging before you find the one you want. 
Also, changing these files isn’t supported so if you mess them up and your IDE
no longer functions correctly either restore the files from the installation CD
or reinstall the product.  Whatever you do don’t come looking for me to fix the
problem!  🙂