diff --git a/docs/docs/getting-started/tutorial.md b/docs/docs/getting-started/tutorial.md index b69e0b22e..8d39c49f1 100644 --- a/docs/docs/getting-started/tutorial.md +++ b/docs/docs/getting-started/tutorial.md @@ -759,7 +759,7 @@ We can also add a link somewhere in the home page of the application to be able ## Refactoring: using template partials -The templates used for creating and updating an article look the same: they both make use of the same schema in order to create or update articles. It would be interesting to be able to reuse this form for both templates. This is where template "partials" cames in handy: these are template snippets that can be easily "included" into other templates to avoid duplications of code. +The templates used for creating and updating an article look the same: they both make use of the same schema in order to create or update articles. It would be interesting to be able to reuse this form for both templates. This is where template "partials" came in handy: these are template snippets that can be easily "included" into other templates to avoid duplications of code. Let's create a `src/templates/partials/article_form.html` partial with the following content: @@ -781,7 +781,7 @@ Let's create a `src/templates/partials/article_form.html` partial with the follo This partial template contains the exact same form that we used in the creation and update templates. -Let's now make use of this partial in the `src/templates/article_create.html` and `src/templates/article_update.html` templates: +Let's now make use of this partial in the `src/templates/article_create.html` and `src/templates/article_update.html` templates by leveraging the [`include`](../templates/reference/tags.md#include) template tag: ```html title="src/templates/article_create.html" {% extend "base.html" %} @@ -803,6 +803,10 @@ Let's now make use of this partial in the `src/templates/article_create.html` an As you can see, the creation and update templates are now much more simple. +:::tip +The `include` template tag provides additional options like the ability to assign variables that are specific to the included template. Please refer to the [`include` template tag reference](../templates/reference/tags.md#include) to learn more about this mechanism. +::: + ## Refactoring: using generic handlers The handlers we implemented previously map to common web development use cases: retrieving data from the database - from a specific URL paramater - and displaying it, listing multiple objects, creating or updating records, etc. These use cases are so frequently encountered that Marten provides a set of "generic handlers" that allow to easily implement them. These generic handlers take care of these common patterns so that developers don't end up reimplementing the wheel. diff --git a/docs/versioned_docs/version-0.4/getting-started/tutorial.md b/docs/versioned_docs/version-0.4/getting-started/tutorial.md index e55a77f2b..bdb708740 100644 --- a/docs/versioned_docs/version-0.4/getting-started/tutorial.md +++ b/docs/versioned_docs/version-0.4/getting-started/tutorial.md @@ -759,7 +759,7 @@ We can also add a link somewhere in the home page of the application to be able ## Refactoring: using template partials -The templates used for creating and updating an article look the same: they both make use of the same schema in order to create or update articles. It would be interesting to be able to reuse this form for both templates. This is where template "partials" cames in handy: these are template snippets that can be easily "included" into other templates to avoid duplications of code. +The templates used for creating and updating an article look the same: they both make use of the same schema in order to create or update articles. It would be interesting to be able to reuse this form for both templates. This is where template "partials" came in handy: these are template snippets that can be easily "included" into other templates to avoid duplications of code. Let's create a `src/templates/partials/article_form.html` partial with the following content: @@ -781,7 +781,7 @@ Let's create a `src/templates/partials/article_form.html` partial with the follo This partial template contains the exact same form that we used in the creation and update templates. -Let's now make use of this partial in the `src/templates/article_create.html` and `src/templates/article_update.html` templates: +Let's now make use of this partial in the `src/templates/article_create.html` and `src/templates/article_update.html` templates by leveraging the [`include`](../templates/reference/tags.md#include) template tag: ```html title="src/templates/article_create.html" {% extend "base.html" %} @@ -803,6 +803,10 @@ Let's now make use of this partial in the `src/templates/article_create.html` an As you can see, the creation and update templates are now much more simple. +:::tip +The `include` template tag provides additional options like the ability to assign variables that are specific to the included template. Please refer to the [`include` template tag reference](../templates/reference/tags.md#include) to learn more about this mechanism. +::: + ## Refactoring: using generic handlers The handlers we implemented previously map to common web development use cases: retrieving data from the database - from a specific URL paramater - and displaying it, listing multiple objects, creating or updating records, etc. These use cases are so frequently encountered that Marten provides a set of "generic handlers" that allow to easily implement them. These generic handlers take care of these common patterns so that developers don't end up reimplementing the wheel.