Variable reference 编辑
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 and in the child components $<varname>
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论