Section generator(章节生成器 (Section generator))¶
:::callout{theme="neutral"} This widget is only available for document templates. :::

The Section generator allows you to dynamically generate document content for every object in an object set. This generation step happens when a Notepad document is generated from the template (see figure above for a visualization of the concept).
To set up a Section generator, add it by clicking + Add Widget or typing / in a paragraph field to open up the widget insertion menu and choosing the Section generator. Then, connect an object set template input by selecting the widget and configuring the Generator object set as shown in the figure below.

Connect embedded sections with generator¶
To connect an embedded widget's input parameter with its surrounding Section Generator, you need to set the parameter to Object from Generator. This parameter will be automatically selectable for widgets inside generators that accept object template inputs.
The figure below shows an example for an object property.

Sort objects with the Section generator¶
To sort the objects that are returned from a generator, use the Sorting controls. Select an object property to sort by from the Sort by dropdown. Note that the number of objects that can be sorted is capped at 2000.
The figure below shows an example of sorting Airline objects by the Number of Aircraft property.

Template configuration¶
- Generator object set RID: An object set to pass to the Section generator. The Section generator content will be generated for each object in this set. Note that the number of objects that can be passed is capped at 30 objects. Objects exceeding this limit will be ignored.
Nested generators¶
Generators can be nested in a top-level section generator. We only support nesting generators one level deep, at most. The top-level section generator object can be configured to generate over an object set template input. A nested generator can be configured to generate over an object set template input, or over first-degree linked objects of the top-level generator object.

Section generator object limits¶
By default, the generation limit for top-level section generators is set to a maximum of 30 objects. For nested section generators, the limit is set to a maximum of 100 objects. Note that generating sections from a large set of objects can negatively impact template generation performance and document loading performance for the generated document.
中文翻译¶
章节生成器 (Section generator)¶
:::callout{theme="neutral"} 此小部件仅适用于文档模板。 :::

章节生成器 (Section generator) 允许您为对象集中的每个对象动态生成文档内容。当从模板生成 Notepad 文档时,会执行此生成步骤(有关概念的可视化说明,请参见上图)。
要设置章节生成器,请点击 + 添加小部件 (+ Add Widget) 或在段落字段中键入 / 打开小部件插入菜单,然后选择章节生成器。接着,通过选择小部件并配置 生成器对象集 (Generator object set) 来连接对象集模板输入,如下图所示。

将嵌入章节与生成器连接¶
要将嵌入小部件的输入参数与其周围的章节生成器连接,您需要将参数设置为 来自生成器的对象 (Object from Generator)。对于生成器内部接受对象模板输入的小部件,此参数将自动可选。
下图展示了对象属性 (object property) 的示例。

使用章节生成器对对象排序¶
要对生成器返回的对象进行排序,请使用排序 (Sorting) 控件。从 排序依据 (Sort by) 下拉菜单中选择一个对象属性作为排序依据。请注意,可排序的对象数量上限为 2000 个。
下图展示了按 飞机数量 (Number of Aircraft) 属性对航空公司对象进行排序的示例。

模板配置¶
- 生成器对象集 RID (Generator object set RID): 传递给章节生成器的对象集。章节生成器内容将为此集合中的每个对象生成。请注意,可传递的对象数量上限为 30 个。超出此限制的对象将被忽略。
嵌套生成器 (Nested generators)¶
生成器可以嵌套在顶层章节生成器中。我们最多仅支持一层深度的生成器嵌套。顶层章节生成器对象可配置为基于对象集模板输入生成内容。嵌套生成器可配置为基于对象集模板输入生成内容,或基于顶层生成器对象的一级关联对象生成内容。

章节生成器对象限制¶
默认情况下,顶层章节生成器的生成限制设置为最多 30 个对象。对于嵌套章节生成器,限制设置为最多 100 个对象。请注意,从大量对象生成章节可能会对模板生成性能以及生成文档的文档加载性能产生负面影响。