string - YAML引用另一个文件中的另一个变量

标签 string reference yaml transclusion

假设我有2个YAML文件:

1)application.yml

en:
  variable: "Hello World"

2)user.yml
en:
  variable: <Here I want to get value from application.yml -> "Hello World" >

起初我虽然可以使用引用:

1)application.yml
en:
  variable: &variable "Hello World"

2)user.yml
en:
  variable: *variable

但是事实证明,只有在一个文件中声明的项目才有可能。
有什么办法可以从application.yml中定义的变量中获取值?

最佳答案

So the only way is to create another, third file that would hold shared values. Or to use the value from "application.yml".

YAML references are intra-file.

You could also have a preprocessing step where you merge YAML files.



在* nix shell中:
cat foo.yaml bar.yaml > baz.yaml

在Powershell中:
cat foo.yaml, bar.yaml > baz.yaml

批量:
type foo.yaml bar.yaml > baz.yaml

引用
  • Look Ma, No Tags!
  • Powershell cmdlets: get-content
  • cat
  • COPY Concatenates Files Based on Command Syntax
  • 关于string - YAML引用另一个文件中的另一个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22639727/

    相关文章:

    java - java hashmaps 的 get() 函数

    C# - 在动态生成的程序集中引用类型

    c++ - 按值、引用和名称调用

    java - 根据 application.yml 中的属性注入(inject) Spring Boot

    java - 格式化字符串日期

    python - 如何使用切片反转列表?

    javascript - REST API 使用 Swagger 和 Node.js 以及 SQL Server 作为数据库

    python - conda 'ImportError: No module named ruamel.yaml.comments'

    java - 将文本文件放入Java中的二维不规则数组

    string - 构建包含用单引号括起来的变量值的 bash 字符串