Variable reference 编辑

When you use the repeat and repeat-item constructs in components to build multiple configuration objects, you can assign a variable name to the repeat-item construct. This variable can be then referenced in the properties of that component or in child components by using the notation $\<varname\>. Note that when the repeat construct is used without the repeat-item construct in a component, a default variable called $repeat-item can be used to access the iteration items.

Example:

components:
  -
    name: server-members-comp
    type: ns::server
    condition: $parameters.svc-server-domain-names
    repeat: $parameters.svc-server-domain-names
    repeat-item: server-name
    properties:
      name: $server-name + "-server"
      domain: $server-name
    components:
      -
         name: service-members-comp
         type: ns::service
         properties:
           name: $server-name + "-service"
           servername: $parent.properties.name
           servicetype: $parameters.svc-service-type
           port: $parameters.svc-server-port
<!--NeedCopy-->

In the above example, a variable name, server-name, is assigned to the repeat-item construct. This variable name is referred to in the properties of the same component as well as in the child components $\<varname\>.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:13 次

字数:1606

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文