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/

    相关文章:

    c# - 字节数组到字数组到字符串

    从十六进制字符串解码 Python UCS2

    string - Bash:完全像 Readline 一样拆分字符串

    c++ - 在c++中直接使用函数返回值作为引用

    java - 当我从数组中使用 fxml 变量作为引用时,为什么它不起作用?

    python - 在 python 中观察变量?

    ansible - 在 YAML 中使用 Enter 处理空格的更漂亮方法

    c++ - 排序程序的错误代码

    java - 更新 gitlab-ci 构建中的 gradle 版本

    yaml - 根据不同的值更改键值