ASP.NET MVC custom T4 templates for views

后端 未结 4 1573
走了就别回头了
走了就别回头了 2020-12-14 04:22

When I\'m adding a new strongly-typed view to an ASP.NET MVC project, I can select between different view content templates (Create Details, Edit, List). I have read these a

相关标签:
4条回答
  • 2020-12-14 04:41

    You might want to take a look at David Hayden's site: http://www.pnpguidance.net/Tag/T4.aspx -- He offers several screencasts on T4 and MVC that got me started. Also take a look at the T4 toolbox: (www.codeplex.com/t4toolbox). This provides additonal helpers for T4 templates.

    0 讨论(0)
  • 2020-12-14 04:50

    Create following folder structure:

    {YourMVCProject}\CodeTemplates\AddView

    Put your custom T4 templates (*.tt) in this folder. You will see the magic!

    0 讨论(0)
  • 2020-12-14 04:53

    You can add a package to your project using NuGet that will add the existing code templates to your project. From that point you could edit them or just create new ones in the same location and you should see them in the tooling.

    http://nuget.org/List/Packages/Mvc3CodeTemplatesCSharp

    0 讨论(0)
  • 2020-12-14 05:05

    ASP.Net MVC - T4 Fun

    T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers

    0 讨论(0)
提交回复
热议问题