.NET Core模板的markdown语法是什么 [英] What is the markdown syntax for .NET Core templating

查看:159
本文介绍了.NET Core模板的markdown语法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .NET Core模板,想知道如何根据设置的标志隐藏markdown文件中的部分内容?

I have a .NET Core template and wondering how I can hide partial content from markdown file based on the flags set?

您可能会在下面看到,我尝试了在CS项目文件中执行的操作,但是没有用.

As you may see below I tried what I do in CS project files but it didn't work.

# 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-->

推荐答案

默认情况下,模板引擎仅在某些文件类型列表中仅支持这些条件运算符,有时语法不同.您可以找到文件列表

The templating engine by default only supports these conditional operators only in a certain list of file types, sometimes with varying syntax. You can find that list of files in the source of the orchestrator. As of now, the list does not include Markdown files though, which is why you are not getting any functionality there.

幸运的是,似乎有一种方法可以配置

Fortunately, there appears to be a way to configure special custom operations on custom file types inside the template.json, which allows you to define custom operations e.g. for conditional operators.

添加类似的内容应该可以:

Adding something like this should work:

"SpecialCustomOperations": {
  "**/*.md": {
    "operations": [
      {
        "type": "conditional",
        "configuration": {
          "if": ["---#if"],
          "else": ["---#else"],
          "elseif": ["---#elseif", "---#elif"],
          "endif": ["---#endif"],
          "trim" : "true",
          "wholeLine": "true",
        }
      }
    ]
  }
}

它应该允许您在.md文件中使用这样的条件:

It should allow you to use conditionals like this in your .md files:

# This is an example Markdown

---#if (FooBar)
Foo bar
---#elif (BarBaz)
Bar baz
---#else
Baz qux
---#endif

请注意,我在这里使用了不同的语法,因为基于单行的语法更易于配置.

Note that I used a different syntax here as a single-line based syntax is a lot easier to configure.

这篇关于.NET Core模板的markdown语法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆