blipson89 / Leprechaun

A template code generation framework for Rainbow
MIT License
42 stars 22 forks source link

Generate renderings constant from rainbow files #36

Open gluip opened 4 years ago

gluip commented 4 years ago

Is there also a way to generate code from rendering definitions? In TDS we had a structure like this for every project. So the rendering ID is available in code

namespace MySite.Feature.Accordion
{ 
  public static partial class Renderings { 
     public static readonly ID TimelineAccordionContainer = new ID("{80cb32f0-caa0-467a-bbdb-cd82f8f1b9c7}") ;  
  }  
}
blipson89 commented 4 years ago

Currently, Leprechaun only can generate models based off of templates. I've toyed around with the idea of pointing it at other parts of the content tree to generate static IDs before but nothing has come of it yet.

The problem is that the code generation revolves around templates as a templates, not templates as items.

I'm going to add the "Enhancement" label to this and do some more digging.

gluip commented 4 years ago

Thanks for the fast reaction. I started fiddling round with the templatePredicate to include renderings but this will not work then.

gluip commented 4 years ago

I created a PR for this (issue_36). I have implemented a optional renderingreader which fills the "Renderings" property. I added a RenderingConstants.csx as an example. The rendering reader should be added for DI.

    <renderingReader type="Leprechaun.InputProviders.Rainbow.RenderingReaders.DataStoreRenderingReader, Leprechaun.InputProviders.Rainbow" singleInstance="true">

    </renderingReader>