Skip to content

Commit 160d18e

Browse files
authored
Update the documentation (#105)
* Rearrange the documentation files * Update the main article * Add an article to explain the vapor integration * Update the getting started article * Update the conversion article * Update the globalization article * Add an article with an element overview * Update some articles * Add articles for the components * Update the articles of the components * Update the abstraction article * Add an article to explain the css deployment * Rename some files * Update some of the articles * Update the readme file * Update some of the articles
1 parent f98464d commit 160d18e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1285
-402
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div align="center">
22
<img src="https://avatars.githubusercontent.com/u/26165732?s=200&v=4" width="100" height="100" alt="avatar" />
33
<h1/>HTMLKit</h1>
4-
<p>Render dynamic HTML templates in a typesafe and performant way! By using Swift's powerful language features and a pre-rendering algorithm, HTMLKit will render insanely fast templates but also catch bugs that otherwise might occur with other templating options.</p>
4+
<p>Create and render HTML templates with HTMLKit.</p>
55
<a href="https://swiftpackageindex.com/vapor-community/htmlkit/documentation">
6-
<img src="https://img.shields.io/badge/Documentation-17.10.2022-red" alt="documentation" />
6+
<img src="https://img.shields.io/badge/Documentation-available-red" alt="documentation" />
77
</a>
88
<a href="https://swiftpackageindex.com/vapor-community/HTMLKit">
99
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fvapor-community%2FHTMLKit%2Fbadge%3Ftype%3Dswift-versions" alt="versions" />

Sources/HTMLKit/Framework/Core/Primitives/Layouts/Layouts.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,13 @@
44
*/
55

66
/// A type that defines a page layout.
7-
///
8-
/// The page covers the whole frame of a hompage. It can contain views and components.
97
public protocol Page: AnyLayout, GlobalElement {
108
}
119

1210
/// A type that defines a view layout.
13-
///
14-
/// The view is a single part of page. It can contain views ad components.
1511
public protocol View: AnyLayout, GlobalElement {
1612
}
1713

1814
/// A type that defines a component layout.
19-
///
20-
/// The component is a partial part of a view or page.
2115
public protocol Component: AnyLayout, GlobalElement {
2216
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Getting started
2+
3+
Learn how to use the framework.
4+
5+
> Important: The framework requires Swift 5.6 or higher.
6+
7+
### Manifest
8+
9+
To use the the framework in your project you need to add it to the package manifest first.
10+
11+
```swift
12+
let package = Package(
13+
...
14+
dependencies: [
15+
// 1. Add the package
16+
.package(url: "https://github.com/vapor-community/HTMLKit.git", from: "2.8.0"),
17+
],
18+
targets: [
19+
.target(
20+
...
21+
dependencies: [
22+
/// 2. Add the product
23+
.product(name: "HTMLKit", package: "HTMLKit"),
24+
]
25+
),
26+
...
27+
]
28+
)
29+
```
30+
31+
Import the module in one of your files next.

Sources/HTMLKit/HTMLKit.docc/Essentials/Getting_started.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

Sources/HTMLKit/HTMLKit.docc/Essentials/Parts/Elements.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

Sources/HTMLKit/HTMLKit.docc/Essentials/Parts/Layouts.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

Sources/HTMLKit/HTMLKit.docc/Essentials/Parts/Statements.md

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Vapor integration
2+
3+
Use the framework together with Vapor.
4+
5+
## Overview
6+
7+
The HTMLKit framework uses the web framework [Vapor](https://swiftpackageindex.com/vapor/vapor) as its standard view renderer.
8+
9+
### Configure
10+
11+
Before you can use the view renderer, you need to do some adjustments in the *configure.swift* file of your Vapor project:
12+
13+
```swift
14+
/// 1. Load the module
15+
import HTMLKitVapor
16+
import Vapor
17+
18+
public func configure(_ app: Application) throws {
19+
20+
/// 2. Specify the view renderer
21+
app.views.use(.htmlkit)
22+
23+
/// 3. Add the layout
24+
app.htmlkit.views.add(view: ExampleTemplate.ExampleView())
25+
26+
try routes(app)
27+
}
28+
```
29+
30+
### Request
31+
32+
Now you can call the method *render* on the request in one of your controllers:
33+
34+
```swift
35+
import Vapor
36+
37+
final class ExampleController {
38+
39+
func getIndex(_ request: Request) async throws -> View {
40+
41+
/// 1. Name the layout
42+
return try await request.view.render("ExampleTemplate.IndexView")
43+
}
44+
}
45+
```

Sources/HTMLKit/HTMLKit.docc/Features/Conversion.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)