Skip to content

Commit

Permalink
#165 - Link to the include template tag reference from the tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
ellmetha committed Feb 22, 2024
1 parent ed50095 commit 9c3c983
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions docs/docs/getting-started/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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" %}
Expand All @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions docs/versioned_docs/version-0.4/getting-started/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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" %}
Expand All @@ -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.
Expand Down

0 comments on commit 9c3c983

Please sign in to comment.