File tree Expand file tree Collapse file tree 1 file changed +6
-34
lines changed Expand file tree Collapse file tree 1 file changed +6
-34
lines changed Original file line number Diff line number Diff line change 1
1
# @elysiajs/html
2
- Plugin for [ elysia] ( https://github.com/elysiajs/elysia ) that add support for returning html.
3
-
4
- ## Installation
5
- ``` bash
6
- bun add @elysiajs/html
7
- ```
8
-
9
- ## Example
10
- ``` typescript
11
- import { Elysia } from ' elysia'
12
- import { html } from ' @elysiajs/html'
13
2
14
- const page = ` <!DOCTYPE HTML>
15
- <html lang="en">
16
- <head>
17
- <title>Hello World</title>
18
- </head>
19
- <body>
20
- <h1>Hello World</h1>
21
- </body>
22
- </html> `
23
-
24
- const app = new Elysia ()
25
- .use (html ())
26
- .get (' /' , () => page )
27
- .get (' /html' , ({ html }) => html (page ))
28
- .listen (8080 )
29
- ```
3
+ Plugin for [ elysia] ( https://github.com/elysiajs/elysia ) that add support for returning html.
30
4
31
- ## API
32
- This plugin detects HTML string and adds ` html ` method to ` Context ` .
5
+ <br />
33
6
34
- If your response is start with ` <!DOCTYPE ` (case insensitive), ` Content-Type ` will be set to ` text/html ` .
7
+ <h3 align =center >
8
+ Documentation at <a href="https://elysiajs.com/plugins/html.html">elysiajs.com/plugins/html</a>
9
+ </h3 >
35
10
36
- Or if you want to manually return HTML, simply use the newly added ` html ` function like this:
37
- ``` typescript
38
- app .get (' /html' , ({ html }) => html (page ))
39
- ```
11
+ <br />
You can’t perform that action at this time.
0 commit comments