aspnet / Templates

This repo is OBSOLETE - please see the README file for information
Other
150 stars 57 forks source link

Sharing Common Files Between Templates #856

Closed RehanSaeed closed 7 years ago

RehanSaeed commented 7 years ago

I have a ReadMe.html file which I'd like to share between my project templates. The file is mostly the same for all three templates, except that it contains a few symbols common to all my templates. I'd like to keep one copy of this file and use symbols to define template specific sections.

<html>
<p>Common paragraph...</p>
<!--#if MyTemplate1-->
<p>MyTemplate1 paragraph...</p>
<!--#endif-->
<!--#if MyTemplate2-->
<p>MyTemplate2 paragraph...</p>
<!--#endif-->
</html>

I can think of a way this might work without any help from the templating engine: Keep a common copy of the file, then copy the file into the template folders as a pre-packaging step in my build script. The disadvantage is that now I have three copies of my file unless I use a .gitignores file but then I have the extra step of having to remove the .gitignores file from the template output.

I propose that you should be able to add a file as a link, then mark that file as common in your template.json file. Finally, when generating the project, the file is converted from a linked file, into a real one.

mlorbetske commented 7 years ago

This issue was moved to dotnet/templating#1179