Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Update editing-templates.md
Browse files Browse the repository at this point in the history
  • Loading branch information
EngincanV committed Feb 29, 2024
1 parent 8793102 commit 8038a29
Showing 1 changed file with 62 additions and 35 deletions.
97 changes: 62 additions & 35 deletions en/abp-suite/editing-templates.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,94 @@
# Editing templates

ABP Suite uses templates to generate the code files. You can see the the template files by clicking "Edit Templates" menu item.
ABP Suite uses templates to generate the code files. You can see the template files by clicking "Edit Templates" menu item.

![Suite template list](../images/suite-templates-8.1.png)

The are 2 template filters:

1. **UI**: You can switch between `Angular` and `MVC` templates.
1. **UI**: You can switch between `Angular`, `MVC` and `Blazor` templates.
2. **Database provider:** You can switch between `EF Core` and `MongoDb` templates.

These filters are automatically selected based on your ABP solution. The selected solution is shown on the top right of the page. In the current screenshot it is "SAM".
These filters are automatically selected based on your ABP solution. The selected solution is shown on the top right of the page. In the current screenshot it is "Acme.BookStore".

ABP Suite templates are embedded resources which are stored in the `Volo.Abp.Commercial.SuiteTemplates` package. When you update your project, Suite templates are also being updated. To be able to generate the correct code for your project, the version of `Volo.Abp.Commercial.SuiteTemplates` must be the same as your Suite version.

## How do I find which template to edit ?

There's a search box in the templates page. To find the related template, pick a unique text from your generated code file and search it. The search, filters by template content.
There's a search box on the templates page. To find the related template, pick a unique text from your generated code file and search it. The search, filters by template content.

There's a naming convention for the template files.

* If the template name has `Server` prefix, it's used for backend code like repositories, application services, localizations, controllers, permissions, mappings, unit tests.
* If the template name has `Frontend.Angular` prefix, it's used for Angular code generation. The Angular code is being generated via [Angular Schematics](https://angular.io/guide/schematics).
* If the template name has `Frontend.Mvc` prefix, it's used for razor pages, menus, JavaScript, CSS files.
* If the template name has `Frontend.Blazor` prefix, it's used for razor components.

## How do I edit the templates?

When you click the Edit button of a template card, you will see the template content and variables of the template. These variables are written in `%%my-variable%%` format.
When you click the **Edit** button of a template card, you will see the template content and variables of the template. These variables are written in `%%my-variable%%` format.

When you edit a template, you will see the "Customized" badge on the template card. You can revert back to the original content by clicking "Revert customization".

![Customized template](../images/suite-customized-template.png)



You may need the variable list while editing a template content.

**Variables:**

These variables are populated based on the following project information;
You may need the variable list while editing a template content. These variables are populated based on the following project information;

* Solution name: **Acme.BookStore**
* Entity type: **Master**
* Entity name: **OrderLine**
* Plural name: **OrderLines**
* Database table: **OrderLines**
* Namespace: **OrderLines**
* Base class: **FullAuditedAggregateRoot**
* Primary key type: **Guid**

| Variable name | Value |
| -------------------------------- | ------------------------------------------------------- |
| %%solution-namespace%% | Acme.BookStore |
| %%solution-namespace-camelcase%% | acme.bookStore |
| %%project-name%% | Acme.BookStore |
| %%only-project-name%% | BookStore |
| %%only-project-name-camelcase%% | bookStore |
| %%entity-namespace%% | OrderLines |
| %%entity-namespace-camelcase%% | orderLines |
| %%entity-name%% | OrderLine |
| %%entity-name-camelcase%% | orderLine |
| %%entity-name-plural%% | OrderLines |
| %%entity-name-plural-kebabcase%% | order-lines |
| %%entity-name-plural-camelcase%% | orderLines |
| %%primary-key%% | Guid |
| %%database-table-name%% | OrderLines |
| %%base-class%% | FullAuditedAggregateRoot |
| %%other-interfaces%% | , IMultiTenant (*if multitenant*) |
| %%default-sorting%% | {0}Price asc |
| %%with-navigation-properties%% | WithNavigationProperties (*if has navigation property*) |
| %%entity-name-prefix%% | OrderLine. (*if has navigation property*) |
| %%entity-name-prefix-camelcase%% | orderLine. (*if has navigation property*) |
| %%entity-name-prefix-nullable%% | orderLine?. (*if has navigation property*) |
| %%module-name-slash-postfix%% | BookStore/ (*for module template*) |
* Page title: **MyOrderLines**
* Menu icon: **fa fa-shopping**

| Variable name | Value |
| ----------------------------------- | ------------------------------------------------------- |
| %%solution-namespace%% | Acme.BookStore |
| %%solution-namespace-camelcase%% | acme.bookStore |
| %%project-name%% | Acme.BookStore |
| %%only-project-name%% | BookStore |
| %%only-project-name-camelcase%% | bookStore |
| %%entity-namespace%% | OrderLines |
| %%entity-namespace-camelcase%% | orderLines |
| %%entity-name%% | OrderLine |
| %%entity-name-computed%% | OrderLine (or OrderLineWithNavigationProperties - if has navigations) |
| %%entity-name-camelcase%% | orderLine |
| %%entity-name-plural%% | OrderLines |
| %%entity-name-plural-kebabcase%% | order-lines |
| %%entity-name-plural-camelcase%% | orderLines |
| %%entity-page-title%% | MyOrderLines (page titles are localized by ABP Suite) |
| %%menu-icon%% | fa-shopping |
| %%primary-key%% | Guid |
| %%database-table-name%% | OrderLines |
| %%base-class%% | FullAuditedAggregateRoot |
| %%other-interfaces%% | , IMultiTenant (*if multitenant*) |
| %%default-sorting%% | {0}Price asc |
| %%with-navigation-properties%% | WithNavigationProperties (*if has navigation property*) |
| %%entity-name-prefix%% | OrderLine. (*if has navigation property*) |
| %%entity-name-prefix-camelcase%% | orderLine. (*if has navigation property*) |
| %%entity-name-prefix-nullable%% | orderLine?. (*if has navigation property*) |
| %%module-name-slash-postfix%% | BookStore/ (*for module template*) |
| %%custom-code-base%% | Base (*if custom code support is enabled*) |
| %%custom-code-abstract-modifier%% | abstract (*if custom code support is enabled*) |
| %%custom-code-partial-modifier%% | partial (*if custom code support is enabled*) |

**Variables for Master / Detail Relationship**:

If you establish a master/detail relationship, there are some variables that are used in templates for code generation. For example, for the `Order` as the master entity and `OrderLine` as the child entity of it, the following variables will be populated with the following values:

| Variable name | Value |
| ----------------------------------------- | --------------------------------------------------------------------------- |
| %%child-master-entity-name%% | Order |
| %%child-entities-namespaces%% | (all namespaces for the child entities of the Order master entity - line by line) |
| %%child-entities-namespaces-razor%% | (all namespaces for the child entities of the Order master entity - line by line - for Blazor UI) |
| %%child-entities-appservice-injections%% | (injects child entity application services to the razor page - e.g. `@inject IOrderLineAppService OrderLineAppService`) |
| %%mapper-ignore-child-entities%% | (mapping ignore statements for the child entities of the master entity - e.g. `.Ignore(x => x.OrderLines)`) |

**Conditions:**

Expand All @@ -83,5 +101,14 @@ Conditions are if statements to render the related code-block. If the condition
| %%<if:IsNonTieredArchitecture>%% %%</if:IsNonTieredArchitecture>%% | if it's not a tiered application template. Means `*.HttpApi.Host` project doesn't exist |
| %%<if:IsTieredArchitecture>%% %%</if:IsTieredArchitecture>%% | if it's a tiered application template. Means `*.HttpApi.Host` project exists |
| %%<if:IsModule>%% %%</if:IsModule>%% | if it's a module template. |
| %%<if:IHasConcurrencyStamp>%% %%</if:IHasConcurrencyStamp>%% | if it's implementing the `IHasConcurrencyStamp` interface or concurrency check is enabled |
| %%<if:PreserveCustomCodeNotEnabled>%% %%</if:PreserveCustomCodeNotEnabled>%% | if the custom code support is not enabled. |
| %%<if:IsChildEntity>%% %%</if:IsChildEntity>%% | if it's a child entity. |
| %%<if:IsMasterWithChildEntities>%% %%</if:IsMasterWithChildEntities>%% | if it's a master entity with child entities. |
| %%<if:HasNavigationProperties>%% %%</if:HasNavigationProperties>%% | if it has navigation properties. |
| %%<if:HasMasterEntityNavigationProperties>%% %%</if:HasMasterEntityNavigationProperties>%% | if it's a master entity and has navigation properties. |
| %%<if:HasFilterableProperties>%% %%</if:HasFilterableProperties>%% | if it has any filterable properties. |
| %%<if:HasAnyFilterableProperties>%% %%</if:HasAnyFilterableProperties>%% | if it has any filterable properties including navigation properties. |
| %%<if:BulkDeleteEnabled>%% %%</if:BulkDeleteEnabled>%% | if the bulk delete is enabled. |


0 comments on commit 8038a29

Please sign in to comment.