mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-16 20:01:46 +01:00
Add info about tag replacements
parent
ce56b70108
commit
5da83e610f
@ -24,5 +24,54 @@ Icon | Category
|
||||
------------ | --------
|
||||
:green_book: | Docs/ page generation
|
||||
:flashlight: | Verification task
|
||||
:pencil2: | Project file udpate
|
||||
:paperclip: | Technical task
|
||||
:pencil2: | Project file update
|
||||
:paperclip: | Technical task
|
||||
|
||||
## Tag replacements
|
||||
Markdown pages in the docs/ folder are created based on a template file. This template file may contain tags which are replaced with data during the generation process. For example:
|
||||
```txt
|
||||
A total of {total} commands are available:
|
||||
|
||||
[#commands]
|
||||
- {name}[perm], requires {perm}[/perm]
|
||||
[/#commands]
|
||||
```
|
||||
|
||||
Three types of tags are available:
|
||||
- Replacement: `{total}`-like tags will be replaced with the value associated with "total"
|
||||
- Conditional: `[perm]...[/perm]`-like tags are conditional tags. The text inside of the tags is only considered if the value associated with "perm" is not empty (empty string / empty collection)
|
||||
- Repeating: tags like `[#commands]...[/#commands]` will make us iterate over all entries in "commands" and apply replacements to the text within
|
||||
|
||||
Values can be associated to tag names with a `TagValueHolder`. Example:
|
||||
```java
|
||||
List<Command> commands = Arrays.asList(
|
||||
new Command("/home", ""), new Command("/help", "permission.help"));
|
||||
|
||||
NestedTagValue commandsInfo = new NestedTagValue();
|
||||
for (Command command : commands) {
|
||||
TagValueHolder commandValues = TagValueHolder.create()
|
||||
.put("name", command.getName())
|
||||
.put("permission", command.getPermission());
|
||||
commandsInfo.add(commandValues);
|
||||
}
|
||||
|
||||
TagValueHolder tagValues = TagValueHolder.create()
|
||||
.put("total", commands.size())
|
||||
.put("commands", commandsInfo);
|
||||
|
||||
// Generate MD file
|
||||
FileIoUtils.generateFileFromTemplate("commands.tpl.md", "commands.md", tagValues);
|
||||
```
|
||||
|
||||
The generated file would look like the following:
|
||||
```md
|
||||
A total of 2 commands are available:
|
||||
|
||||
- /home
|
||||
- /help, requires permission.help
|
||||
```
|
||||
|
||||
The following predefined tags are at your disposal:
|
||||
- `{gen_date}`: generation date (i.e. current date)
|
||||
- `{gen_warning}`: comment warning not to edit the output file directly
|
||||
- `{gen_footer}`: info footer with a link to the repo and the generation date
|
Loading…
Reference in New Issue
Block a user