dotnet/templating

how to create an arbitrarily long directory tree based on user input

ahmednfwela opened this issue · 1 comments

I have a template with the following folder structure:

sourceName: A.B.C

A
-- B
---- C
------ v1
-------- file1
-------- file2

I want the user to input the name as "E.G" for example and the template would match the folder structure to the name, so the generated result would be:

E
-- G
---- v1
------ file1
------ file2

I have solved this using fileRename

{    
    "sourceName": "A.B.C",
    "symbols": {        
        "directoryPath": {
            "type": "derived",
            "valueSource": "name",
            "valueTransform": "dotToPath",
            "replaces": "A/B/C",
            "fileRename": "A/B/C"
        }
    },
    "forms": {     
        "dotToPath": {
            "identifier": "replace",
            "pattern": "\\.",
            "replacement": "/"
        }
    }
}