-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add CustomProperty as a default case to the converter if the attribute isn't implemented yet. * Add charset and http-equiv as attribute case to the converter * Undo the RawRepresentable on enum types since the converter cannot parse it * Make the stringValue lowercased, since the rawValue init of a type seems to be case-sensitive * Add parent differentiation since different parents uses different types * Rename types for code consistency * Add a new role type * Mark the function handler with string value of the RoleAttribute as deprecated * Update the instructions * Update the instructions and the readme * Resolve issues
- Loading branch information
1 parent
2637ef7
commit 50df5f1
Showing
27 changed files
with
898 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,67 @@ | ||
# Localization | ||
|
||
The localization is | ||
HTMLKit can render your content in different languages by using Localization. | ||
|
||
## Essential | ||
|
||
### Registration | ||
|
||
The localization is optional, so if you want to use it, you need to register it first. Pass the directory path and the local identifier to the renderer. Keep in mind, that the directory path is the root directory where your localization files are located. | ||
|
||
```swift | ||
/// [configure.swift] | ||
|
||
... | ||
try Renderer().registerLocalization(atPath: path, defaultLocale: "en") | ||
try app.htmlkit.renderer.registerLocalization(atPath: path, defaultLocale: "en") | ||
... | ||
``` | ||
|
||
### Definition | ||
|
||
Define your localizations in a .json file. If you want to get to know more about definitions, take a a look at the [Lingo library](https://github.com/miroslavkovac/Lingo#usage). | ||
|
||
```swift | ||
/// [en.json] | ||
|
||
{ | ||
"Hallo.Welt": "Hello World" | ||
} | ||
``` | ||
|
||
### Implementation | ||
|
||
You can retrieve the definition by calling the localized initialiser of a localizable element. Most of the phrasing elements in HTMLKit should be localizable and provide you with the specific initialiser. Please [open an issue](https://github.com/vapor-community/HTMLKit/issues), if you find an element without it. | ||
|
||
```swift | ||
/// [IndexView.swift] | ||
|
||
struct IndexView: View { | ||
|
||
var body: AnyContent { | ||
Article { | ||
Heading1("Hallo.Welt") | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Also the locale for the environment can be changed for example by user input. Use the environment modifier on the element and pass the specific local identifier for it. | ||
|
||
```swift | ||
/// [IndexView.swift] | ||
|
||
struct IndexView: View { | ||
|
||
struct Context { | ||
let date: Date | ||
let locale: String | ||
} | ||
|
||
var body: AnyContent { | ||
Article { | ||
... | ||
} | ||
.environment(locale: context.locale) | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,50 @@ | ||
# Overview | ||
|
||
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. | ||
The instructions will provide you with information how to integrate HTMLKit in your project and how you can use it to write HTML by using Swift. Keep in mind, that the instructions are mainly based on a use in a vapor project. | ||
|
||
If still things are unclear, dont hesitate to [open an issue](https://github.com/vapor-community/HTMLKit/issues) or [join the discussions](https://github.com/vapor-community/HTMLKit/discussions). Also you find us on the vapor discord server. | ||
|
||
## Index | ||
1. Installation | ||
|
||
1. [Installation](Instructions/Installation.md) | ||
|
||
This section explains how to integrate the library in your project. | ||
|
||
2. Essential | ||
2.1 Elements | ||
2.2 Layouts | ||
2.3 Context | ||
2.4 Statements | ||
|
||
2.1 [Elements](Essential/Elements.md) | ||
|
||
This section gives an insight about the elements and how you can use it to write html. | ||
|
||
2.2 [Layouts](Essential/Layouts.md) | ||
|
||
This section gives an insight about the layouts and how you can use it to build a template system. | ||
|
||
2.3 [Context](Essential/Context.md) | ||
|
||
This section teaches you... | ||
|
||
2.4 [Statements](Essential/Statements.md) | ||
|
||
This section teaches you, how you can use statements for control flow. | ||
|
||
3. Features | ||
3.1 Localization | ||
3.2 Conversion | ||
3.3 Templating | ||
|
||
3.1 [Localization](Features/Localization.md) | ||
|
||
3.2 [Conversion](Features/Conversion.md) | ||
|
||
3.3 [Templating](Features/Templating.md) | ||
|
||
|
||
4. Example | ||
|
||
## References | ||
4.1 [Code](https://github.com/vapor-community/HTMLKit/tree/main/Instructions/Example/Page) | ||
|
||
Shows a code example. | ||
|
||
4.2 [Wiki](https://github.com/vapor-community/HTMLKit/wiki) | ||
|
||
Informations about the public api. | ||
|
||
## License |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.