Browse Source

Merge pull request #21017 from abpframework/abp-generate-razor-page

Introduce `abp generate-razor-page` command.
pull/21018/head
Engincan VESKE 1 year ago
committed by GitHub
parent
commit
4fcd9b48cb
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 113
      docs/en/cli/index.md
  2. BIN
      docs/en/framework/ui/angular/images/angular-advanced-entity-filters-with-custom-content-above-filter.png
  3. BIN
      docs/en/framework/ui/angular/images/angular-advanced-entity-filters-with-form.png
  4. BIN
      docs/en/framework/ui/angular/images/angular-advanced-entity-filters-without-form.png
  5. BIN
      docs/en/framework/ui/angular/images/angular-advanced-entity-filters.png
  6. BIN
      docs/en/framework/ui/angular/images/manage-profile-page-new-tab.png
  7. BIN
      docs/en/framework/ui/angular/images/manage-profile-page.png
  8. BIN
      docs/en/images/abp-generate-razor-page.png
  9. BIN
      docs/en/images/abp-overall-diagram-1600.png
  10. BIN
      docs/en/images/abp-overall-diagram.png

113
docs/en/cli/index.md

@ -70,6 +70,7 @@ Here, is the list of all available commands before explaining their details:
* **`clear-download-cache`**: Clears the templates download cache.
* **`check-extensions`**: Checks the latest version of the ABP CLI extensions.
* **`install-old-cli`**: Installs old ABP CLI.
* **`generate-razor-page`**: Generates a page class that you can use it in the ASP NET Core pipeline to return an HTML page.
### help
@ -964,6 +965,118 @@ Usage:
abp install-old-cli [options]
```
### generate-razor-page
`generate-razor-page` command to generate a page class and then use it in the ASP NET Core pipeline to return an HTML page.
Usage:
1. Create a new `Razor Page(MyPage.cshtml)` that inherits from `AbpCompilationRazorPageBase` in `Views` folder.
2. Create a `MyPageModel` class in the same folder.
3. Create a `MyPage.js` and `MyPage.css` files in the same folder.
4. Add the following code to the `MyPage.cshtml`, `MyPage.css` and `MyPage.js` files.
```cs
public class MyPageModel
{
public string Message { get; set; }
public MyPageModel(string message)
{
Message = message;
}
}
```
```cs
@using System.Globalization
@using Volo.Abp.AspNetCore.RazorViews
@inherits AbpCompilationRazorPageBase
@{
Response.ContentType = "text/html; charset=utf-8";
Response.StatusCode = 200;
}
@functions{
public MyPage(MyPageModel model)
{
Model = model;
}
public MyPageModel Model { get; set; }
}
<html lang="@HtmlEncoder.Encode(CultureInfo.CurrentCulture.Name)">
<head>
<meta charset="utf-8" />
<style>
<%$ include: MyPage.css %>
</style>
<title>@HtmlEncoder.Encode(Model.Message)</title>
</head>
<body>
<h3>@HtmlEncoder.Encode(Model.Message)</h3>
<ul class="list-group">
@for(int i = 0; i < 10; i++)
{
<li class="list-group-item">@i item</li>
}
</ul>
<script>
//<!--
<%$ include: MyPage.js %>
//-->
</script>
</body>
</html>
```
```css
body {
background-color: #65b2ff;
color: #495057;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
```
```js
console.log('MyPage.js loaded!');
```
5. Finally, run the `generate-razor-page` command under the `Views` folder:
```bash
> abp generate-razor-page
Generating code files for pages in /MyProject/Views
Generating code file for page MyPage.cshtml ...
Inlining file MyPage.css
Inlining file MyPage.js
Done!
1 files successfully generated.
```
The output will be like in the above command output, and `MyPage.Designer.cs` file will be created in the same folder. It's a standard C# class that you can use it in the pipeline to return an HTML page:
```cs
app.Use(async (httpContext, next) =>
{
if (true) // Your condition
{
var page = new MyPage(new MyPageModel("Test message"));
await page.ExecuteAsync(httpContext);
}
else
{
await next();
}
});
```
![Razor Page](./../images/abp-generate-razor-page.png)
#### Options
* ```--version``` or ```-v```: Specifies the version for ABP CLI to be installed.

BIN
docs/en/framework/ui/angular/images/angular-advanced-entity-filters-with-custom-content-above-filter.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 35 KiB

BIN
docs/en/framework/ui/angular/images/angular-advanced-entity-filters-with-form.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 31 KiB

BIN
docs/en/framework/ui/angular/images/angular-advanced-entity-filters-without-form.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
docs/en/framework/ui/angular/images/angular-advanced-entity-filters.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 36 KiB

BIN
docs/en/framework/ui/angular/images/manage-profile-page-new-tab.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 21 KiB

BIN
docs/en/framework/ui/angular/images/manage-profile-page.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 31 KiB

BIN
docs/en/images/abp-generate-razor-page.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

BIN
docs/en/images/abp-overall-diagram-1600.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 547 KiB

After

Width:  |  Height:  |  Size: 407 KiB

BIN
docs/en/images/abp-overall-diagram.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 KiB

After

Width:  |  Height:  |  Size: 286 KiB

Loading…
Cancel
Save