locked
T4 text templates RRS feed

  • Question

  • User-1630302068 posted

     Does anyone know if I can use T4 text templates inside my applications?  I've got lots of email / file generation that I'd like to replace with templates.

    Tuesday, September 30, 2008 3:20 PM

Answers

  • User-1573490007 posted

    Yes you can, but its a bit harder than it should be (not the end of the world though). You need to make a custom T4 host.

    The doc for that is here:

    http://msdn.microsoft.com/en-us/library/bb126519.aspx

    Often I find it simpler to make my own "template engine", using tokens and regex to simply search & replace values from a dictionary or something.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 30, 2008 3:22 PM

All replies

  • User-1573490007 posted

    Yes you can, but its a bit harder than it should be (not the end of the world though). You need to make a custom T4 host.

    The doc for that is here:

    http://msdn.microsoft.com/en-us/library/bb126519.aspx

    Often I find it simpler to make my own "template engine", using tokens and regex to simply search & replace values from a dictionary or something.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 30, 2008 3:22 PM
  • User-1630302068 posted

     Thanks a ton man that was exactly what I was looking for.  FYI I posted this in the 'wrong' forum and have a request in to have it moved to the VS 2k8 forum.  So if it disappears thats where it went.

    Tuesday, September 30, 2008 3:29 PM