www.coder.work /article/6856189

string - YAML引用另一个文件中的另一个变量 - IT工具网

2-2 minutes

标签 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/

    上一篇:glsl es 2.0 逆矩阵

    下一篇:apache - 在我的情况下如何解决 svn : E195019: Redirect cycle detected,?

    ::...
    免责声明:
    当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
    内容版权归原作者所有;
    本人对内容的有效性/合法性不承担任何强制性责任.
    若有不妥, 欢迎评注提醒:

    或是邮件反馈可也:
    askdama[AT]googlegroups.com


    订阅 substack 体验古早写作:


    点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

    关注公众号, 持续获得相关各种嗯哼:
    zoomquiet


    自怼圈/年度番新

    DU22.4
    关于 ~ DebugUself with DAMA ;-)
    粤ICP备18025058号-1
    公安备案号: 44049002000656 ...::