I can't find any MSFT resources on this, and am unsure if it's even possible. But could someone please advise how I would go about embedding an image in a T4 template please?
Asked
Active
Viewed 220 times
1
-
2The T4 template generates c# code, so what do you mean by embed an image in it? – Dr. Andrew Burnett-Thompson Mar 12 '19 at 11:13
-
in the `.tt` template file, I'd like for there to be a static image included – George Grainger Mar 12 '19 at 11:15
-
Still doesn't make any sense, sorry. It's like saying 'I want to show an image in a text file' and no, you can't do that. What's the reason you want to do that / the desired goal? – Dr. Andrew Burnett-Thompson Mar 12 '19 at 11:17
-
The .tt is executed on save, so you should be able to decode an image and save it to disk upon saving of the file. But why don't you include the file in the first place? Is the image generated? – Caramiriel Mar 12 '19 at 11:18
-
So from my understanding, the `.tt` file is interpreted and a text file is produced from the template. I want to produce a HTML file, and have an image in that – George Grainger Mar 12 '19 at 11:26
-
So your question is how to embed an image in an html file...? https://stackoverflow.com/questions/2807251/can-i-embed-a-png-image-into-an-html-page – canton7 Mar 12 '19 at 11:27
-
HTML does not allow binary images to be directly embedded. You have to convert binary image to a BASE 64 string before inserting in html. See wiki : https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references – jdweng Mar 12 '19 at 11:28
-
If that's how you do it, then yes. But given I'm unfamiliar with T4, I wasn't sure it was that simple. – George Grainger Mar 12 '19 at 11:29
-
This has nothing to do with T4 – canton7 Mar 12 '19 at 11:32