将参数传递给嵌套模板
pass parameter to nested template
我正在尝试在我们的 wiki 中设置一个页面,其中包含我们软件中特定操作员的某些参数。
软件中的每个参数都可以是特定类型,例如 "Menu" 或 "Toggle".
所以我想我会创建 2 个模板。第一个称为 "Parameter",第二个称为 "Menu"。
参数模板如下所示:
'''{{{label}}}''' <code>{{{name}}}</code> - {{{summary}}}
{{{items}}}
菜单模板如下所示:
* {{{label}}} <code>{{{name}}}</code> - {{{summary}}}
我的页面内容如下所示:
{{Parameter
|type=menu
|label=Interpolation
|name=interp
|items=
{{
{{menu|name=nointerp|label=No Interpolation|summary=Use the value of the nearest sample.}}
|{{menu|name=linear|label=Linear|summary=Use linear interpolation between samples when the interval is lengthened. Averages all samples near the new sample when the interval is shortened.}}
|{{menu|name=cubic|label=Cubic|summary=Cubically interpolates between samples, for smoother curves than Linear. This method is not recommended for channels with sharp changes.}}
|{{menu|name=edge|label=Pulse Preserve|summary=A linear interpolation that recognizes single sample pulses and preserves their height and one sample width. A pulse is a non-zero value preceded and followed by zero-value samples.}}
}}
|summary=The interpolation method to use when resampling.}}
这几乎可以工作,但我得到了额外的字符,如“{”和“|”呈现在实际页面上。
我想我的问题是:是否可以按照我这样做的方式将参数传递给 "sub-templates"?
非常感谢
如评论中所述,我认为此方法的工作方式存在概念性问题。
我不需要将参数传递给子模板,而是使用传递的参数调用另一个模板。
因此,正确工作的版本如下所示(items 参数未包含在 curley 括号中):
{{Parameter
|type=menu
|label=Interpolation
|name=interp
|items=
{{menu|name=nointerp|label=No Interpolation|summary=Use the value of the nearest sample.}}
|{{menu|name=linear|label=Linear|summary=Use linear interpolation between samples when the interval is lengthened. Averages all samples near the new sample when the interval is shortened.}}
|{{menu|name=cubic|label=Cubic|summary=Cubically interpolates between samples, for smoother curves than Linear. This method is not recommended for channels with sharp changes.}}
|{{menu|name=edge|label=Pulse Preserve|summary=A linear interpolation that recognizes single sample pulses and preserves their height and one sample width. A pulse is a non-zero value preceded and followed by zero-value samples.}}
|summary=The interpolation method to use when resampling.}}
请注意,这将导致菜单作为参数 items
、1
、2
和 3
传递。我想你想要的是将它们全部作为 items
参数传递,在这种情况下你需要删除外部 |
标记。
我正在尝试在我们的 wiki 中设置一个页面,其中包含我们软件中特定操作员的某些参数。 软件中的每个参数都可以是特定类型,例如 "Menu" 或 "Toggle".
所以我想我会创建 2 个模板。第一个称为 "Parameter",第二个称为 "Menu"。
参数模板如下所示:
'''{{{label}}}''' <code>{{{name}}}</code> - {{{summary}}}
{{{items}}}
菜单模板如下所示:
* {{{label}}} <code>{{{name}}}</code> - {{{summary}}}
我的页面内容如下所示:
{{Parameter
|type=menu
|label=Interpolation
|name=interp
|items=
{{
{{menu|name=nointerp|label=No Interpolation|summary=Use the value of the nearest sample.}}
|{{menu|name=linear|label=Linear|summary=Use linear interpolation between samples when the interval is lengthened. Averages all samples near the new sample when the interval is shortened.}}
|{{menu|name=cubic|label=Cubic|summary=Cubically interpolates between samples, for smoother curves than Linear. This method is not recommended for channels with sharp changes.}}
|{{menu|name=edge|label=Pulse Preserve|summary=A linear interpolation that recognizes single sample pulses and preserves their height and one sample width. A pulse is a non-zero value preceded and followed by zero-value samples.}}
}}
|summary=The interpolation method to use when resampling.}}
这几乎可以工作,但我得到了额外的字符,如“{”和“|”呈现在实际页面上。
我想我的问题是:是否可以按照我这样做的方式将参数传递给 "sub-templates"?
非常感谢
如评论中所述,我认为此方法的工作方式存在概念性问题。 我不需要将参数传递给子模板,而是使用传递的参数调用另一个模板。 因此,正确工作的版本如下所示(items 参数未包含在 curley 括号中):
{{Parameter
|type=menu
|label=Interpolation
|name=interp
|items=
{{menu|name=nointerp|label=No Interpolation|summary=Use the value of the nearest sample.}}
|{{menu|name=linear|label=Linear|summary=Use linear interpolation between samples when the interval is lengthened. Averages all samples near the new sample when the interval is shortened.}}
|{{menu|name=cubic|label=Cubic|summary=Cubically interpolates between samples, for smoother curves than Linear. This method is not recommended for channels with sharp changes.}}
|{{menu|name=edge|label=Pulse Preserve|summary=A linear interpolation that recognizes single sample pulses and preserves their height and one sample width. A pulse is a non-zero value preceded and followed by zero-value samples.}}
|summary=The interpolation method to use when resampling.}}
请注意,这将导致菜单作为参数 items
、1
、2
和 3
传递。我想你想要的是将它们全部作为 items
参数传递,在这种情况下你需要删除外部 |
标记。