.NET Core 模板的 markdown 语法是什么
What is the markdown syntax for .NET Core templating
我有一个 .NET Core template,想知道如何根据标志集隐藏 markdown 文件中的部分内容?
正如您在下面看到的,我尝试了我在 CS 项目文件中所做的操作,但没有成功。
README.md
# Steps
- createSolutionFile.ps1
<!--#if (CacheSqlServer)-->
- sql-cache.ps1
1. create database `DistributedCache`
2. create schema `cache`
3. run the script
<!--#endif-->
- user-secrets.ps1
<!--#if (EntityFramework)-->
- scaffold.ps1
- migrate.ps1
<!--#endif-->
- build.ps1
<!--#if (WindowsService)-->
- windows-service.ps1
<!--#endif-->
默认情况下,模板引擎仅在特定的文件类型列表中支持这些条件运算符,有时具有不同的语法。您可以找到该文件列表 in the source of the orchestrator。截至目前,该列表不包括 Markdown 文件,这就是为什么您在那里没有获得任何功能的原因。
幸运的是,似乎有一种方法可以配置 special custom operations on custom file types inside the template.json
, which allows you to define custom operations 例如对于条件运算符。
添加这样的内容应该有效:
"SpecialCustomOperations": {
"**/*.md": {
"operations": [
{
"type": "conditional",
"configuration": {
"if": ["---#if"],
"else": ["---#else"],
"elseif": ["---#elseif", "---#elif"],
"endif": ["---#endif"],
"trim" : "true",
"wholeLine": "true",
}
}
]
}
}
它应该允许您在 .md
文件中使用这样的条件:
# This is an example Markdown
---#if (FooBar)
Foo bar
---#elif (BarBaz)
Bar baz
---#else
Baz qux
---#endif
请注意,我在这里使用了不同的语法,因为基于单行的语法更容易配置。
我有一个 .NET Core template,想知道如何根据标志集隐藏 markdown 文件中的部分内容?
正如您在下面看到的,我尝试了我在 CS 项目文件中所做的操作,但没有成功。
README.md
# Steps
- createSolutionFile.ps1
<!--#if (CacheSqlServer)-->
- sql-cache.ps1
1. create database `DistributedCache`
2. create schema `cache`
3. run the script
<!--#endif-->
- user-secrets.ps1
<!--#if (EntityFramework)-->
- scaffold.ps1
- migrate.ps1
<!--#endif-->
- build.ps1
<!--#if (WindowsService)-->
- windows-service.ps1
<!--#endif-->
默认情况下,模板引擎仅在特定的文件类型列表中支持这些条件运算符,有时具有不同的语法。您可以找到该文件列表 in the source of the orchestrator。截至目前,该列表不包括 Markdown 文件,这就是为什么您在那里没有获得任何功能的原因。
幸运的是,似乎有一种方法可以配置 special custom operations on custom file types inside the template.json
, which allows you to define custom operations 例如对于条件运算符。
添加这样的内容应该有效:
"SpecialCustomOperations": {
"**/*.md": {
"operations": [
{
"type": "conditional",
"configuration": {
"if": ["---#if"],
"else": ["---#else"],
"elseif": ["---#elseif", "---#elif"],
"endif": ["---#endif"],
"trim" : "true",
"wholeLine": "true",
}
}
]
}
}
它应该允许您在 .md
文件中使用这样的条件:
# This is an example Markdown
---#if (FooBar)
Foo bar
---#elif (BarBaz)
Bar baz
---#else
Baz qux
---#endif
请注意,我在这里使用了不同的语法,因为基于单行的语法更容易配置。