Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Single File Generator for Visual Studio #38

Open
gtbuchanan opened this issue Nov 8, 2018 · 2 comments
Open

Add Single File Generator for Visual Studio #38

gtbuchanan opened this issue Nov 8, 2018 · 2 comments

Comments

@gtbuchanan
Copy link

gtbuchanan commented Nov 8, 2018

It's possible to have Visual Studio generate a file on save of another file using a Single File Generator. T4 templates use the built-in TextTemplatingFileGenerator, but I believe other custom generators can be installed by a Visual Studio Extension.

It'd be great to have this functionality with Mustache templates as well.

Getting it working on .NET Standard

@Romanx
Copy link
Contributor

Romanx commented Nov 11, 2018

Hi @gtbuchanan,

I don't actually think i've ever used the functionality in visual studio so am not entirely sure what it'd be used for. What would you like the file to be transformed in to, a .cs file? If so i'd probably recommend Scripty over this since it's a much more fully featured tool. I'd be interested in hearing your ideas though.

@gtbuchanan
Copy link
Author

@Romanx With T4, the generator functionality is used to automatically create the resulting file when the template is saved in Visual Studio. However, T4 has a built-in construct for defining the output file extension:

<#@ output extension=".cs" #>

After thinking about it a little longer, the following would be required for this to work:

  1. The template would need to define the output file extension. One idea is to require the extension to be in the file name. For example: Glyphicons.cs.mustache
  2. The template would need to know where to get the data to use. This is easy with T4 because you can load files from the template. Not too sure about this one for Mustache. Perhaps it could rely on an accompaning JSON file. For example: Glyphicons.json

I was not aware of Scripty. Considering these things, you might be right about Scripty being a better choice. Though there is a current issue about 3rd party references being a pain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants