Visual Studio Python Template Conditional Code

28 views Asked by At

I am working on building a Visual Studio python template. During the project creation I want the user to be able to check a box to add additional code to the project during creation. I have the checkbox in the project creation screen. However, when I look at the source code I see the if statements that is used for the conditional. How do I create a python template that will not have the if in the resulting project?

template.json

{
    "$schema": "http://json.schemastore.org/template",
    "author": "me",
    "classifications": [ "python", ...],
    "identity": "MyTemplate",
    "name": "My Template",
    "shortName": "My Tempalte",
    "sourceName": "py_Hybrid",
    "tags": {
        "language": "Python",
        "platform": "Windows",
        "type": "project"
    },
    "preferNameDirectory": true,
    "symbols": {
        "IncludeSetUpPlugin": {
            "type": "parameter",
            "description": "Include plugin setup.",
            "datatype": "bool",
            "defaultValue": "false"
        }
    }
}

someFile.py

...
{% if IncludeSetUpPlugin %}
from somthing import theOtherThing
{% endif %}
...

I have also tried:

...
@*#if(IncludeSetUpPlugin)
from somthing import theOtherThing
#endif*@
...
0

There are 0 answers