> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/thymeleaf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/thymeleaf/i.-using-thymeleaf/4-standard-expression-syntax/4.5-fragments.md).

# 4.5 分段

分段表达式是代表标记段落，在模版间移动它们的简单的方法。这允许我们复制它们，把它们作为参数传递给其它模版，等等。

分段插入是最普遍的用法，使用`th:insert`或者`th:replace`（在之后的章节会有更多关于这些的内容）：

```markup
<div th:insert="~{commons :: main}">...</div>
```

但是，它们可以在任何地方使用，就像其它的变量一样：

```markup
<div th:with="frag=~{footer :: #main/text()}">
  <p th:insert="${frag}">
</div>
```

在此教程的后面部分，有一个完整的章节专注于模版设计，包括对分段表达式的更深层次的探索。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://jack80342.gitbook.io/thymeleaf/i.-using-thymeleaf/4-standard-expression-syntax/4.5-fragments.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
