.NET Core模板的markdown语法是什么

编程入门 行业动态 更新时间:2024-10-23 20:24:53
本文介绍了.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-->

推荐答案

默认情况下,模板引擎仅在某些文件类型列表中仅支持这些条件运算符,有时语法不同.您可以找到文件列表在协调器的来源中.到目前为止,列表中还没有包含Markdown文件,这就是为什么您在那里没有任何功能的原因.

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.

幸运的是,似乎有一种方法可以配置对template.json内的自定义文件类型的特殊自定义操作,它使您可以定义自定义操作例如对于条件运算符.

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语法是什么

本文发布于:2023-11-15 08:04:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1592630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法   模板   NET   Core   markdown

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!