LaubPlusCo / LaubPlusCo.Helix.VsTemplates

Visual Studio extension that accelerates creating new Visual Studio solutions and projects that follow the conventions described in Sitecore Helix. Install extension from Visual Studio Marketplace
https://marketplace.visualstudio.com/items?itemName=AndersLaublaubplusco.SitecoreHelixVisualStudioTemplates
Other
30 stars 17 forks source link

Support for conditional $if$ #20

Open richardszalay opened 5 years ago

richardszalay commented 5 years ago

Visual Studio's templating engine supports $if$ conditionals in its files so it would be good to support them here. Is this something you'd be happy to accept a PR for?

richardszalay commented 5 years ago

(Since you're effectively using a custom vstemplate format, it would also be nice to support conditionally including projects or excluding files - but that wouldn't necessarily be part of this initial PR)

anderslaub commented 4 years ago

I have made something slightly different that was faster to implement. It might serve the same purpose - to some degree at least. On paths in the manifest you can now add a "condition" which in first release just support a boolean string, and not operator ! (ex. <ignorePath><folder path="/$layername$/$moduleName$/serialization" condition="!$IncludeSerializationFolder$" />...

For now it ootb just works with the value of a input="checkbox" token. Then part of the template content can be ignored if a checkbox is checked/not checked.

You can write your own conditions that extend IEvaluateCondition and then add a type="YourStuff.Namespace.CrazyExpressionValidator, YourStuff" to the file or folder element in <ignorePaths> (previously <ignoreFiles>)<skipPaths> and projectsToAttach.

For later, I have been considering to extend the dotnetnew templateengine but lack the time to get started on this. This would enable support for all the VS templating plus still keep all the added goodness and structure from having the manifest files etc etc. Perhaps sometime later in the year..