I was looking for a way to automatically generate Glass Models for my Sitecore Templates that had been serialized using Unicorn’s Rainbow YAML serialization formatter and came across this post by Sitecore MVP Robin Hermanussen – http://hermanussen.eu/sitecore/wordpress/2015/04/generating-sitecore-code-without-tds
After reading the documents on GitHub it sounded perfect so I forked the repo and took a look at what the project was doing – https://github.com/hermanussen/sitecore.codegenerator
My first step were :-
Then I made some updates to the models that were being outputted using the T4 helpers from the tds-codegen project – https://github.com/HedgehogDevelopment/tds-codegen
Changed to GlassGenerator :-
Changes to GlassMappedClassTemplate :-
Here is the original output :-
And this is what Sitecore.CodeGenerator is outputting now with my changes:-
Have a play with the code – https://github.com/Wesley-Lomax/sitecore.codegenerator and checkout Robins repo – https://github.com/hermanussen/sitecore.codegenerator I’ve found it a great timesaver for boiler plate models for your renderings.