-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0289511
commit ca20b6a
Showing
28 changed files
with
507 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "⚡ Advanced", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Advanced concepts" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Safe Mode | ||
|
||
When using a wide glob pattern (such as `*/**`), utpp may match files that you don't want to be processed like compiled binaries etc. | ||
This could result in the following errors if utpp tries to match a pattern in them: | ||
|
||
``` | ||
foo.txt: Command '$[�u�`�F�C���2���%�bԪ]$' found but it is not part of any block. | ||
foo.txt: Found 1 unmatched commands. Please check your syntax. | ||
``` | ||
|
||
or | ||
|
||
``` | ||
bar.txt: Command '�Z��C��9�' does not exist. | ||
``` | ||
|
||
To prevent this, you can use the `--safe` flag. This will cause utpp to only process files that contains the string `///utpp` anywhere in the file. | ||
This is a good way to ensure that utpp only processes files that you want it to if you are unable to restrict your glob pattern. | ||
All occurances of `///utpp` will be removed from the file. | ||
|
||
### Ignore unkown commands | ||
|
||
As an alternative to safe mode, you can use the `--ignore-unknown` flag. This will cause utpp to ignore any commands that it doesn't recognize. | ||
If a command is not recognized in a block, the entire block will be ignored (unchanged). | ||
|
||
:::caution | ||
Typos in commands will be ignored with this flag and no error will be thrown. This could result in unwanted behavior. | ||
::: | ||
|
||
:::info | ||
This flag only checks for unkown **commands**, not variables. | ||
::: |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "⚡ Advanced", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Advanced concepts" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Safe Mode | ||
|
||
When using a wide glob pattern (such as `*/**`), utpp may match files that you don't want to be processed like compiled binaries etc. | ||
This could result in the following errors if utpp tries to match a pattern in them: | ||
|
||
``` | ||
foo.txt: Command '$[�u�`�F�C���2���%�bԪ]$' found but it is not part of any block. | ||
foo.txt: Found 1 unmatched commands. Please check your syntax. | ||
``` | ||
|
||
or | ||
|
||
``` | ||
bar.txt: Command '�Z��C��9�' does not exist. | ||
``` | ||
|
||
To prevent this, you can use the `--safe` flag. This will cause utpp to only process files that contains the string `///utpp` anywhere in the file. | ||
This is a good way to ensure that utpp only processes files that you want it to if you are unable to restrict your glob pattern. | ||
All occurances of `///utpp` will be removed from the file. | ||
|
||
### Ignore unkown commands | ||
|
||
As an alternative to safe mode, you can use the `--ignore-unknown` flag. This will cause utpp to ignore any commands that it doesn't recognize. | ||
If a command is not recognized in a block, the entire block will be ignored (unchanged). | ||
|
||
:::caution | ||
Typos in commands will be ignored with this flag and no error will be thrown. This could result in unwanted behavior. | ||
::: | ||
|
||
:::info | ||
This flag only checks for unkown **commands**, not variables. | ||
::: |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "🤖 API Reference", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "API Reference" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Commands | ||
|
||
## Commands without side effects | ||
|
||
`if <value>` - return true when `<value>` is truthy, otherwise false. | ||
|
||
`ifdef <name>` - return true when a variable with name `<name>` is defined, otherwise false. | ||
|
||
`ifndef <name>` - return true when a variable with name `<name>` is not defined, otherwise false. | ||
|
||
`ifeq <value1> <value2>` - return true when `<value1>` is equal to `<value2>`, otherwise false. | ||
|
||
`ifne <value1> <value2>` - return true when `<value1>` is not equal to `<value2>`, otherwise false. | ||
|
||
`iflt <value1> <value2>` - return true when `<value1>` is less than `<value2>`, otherwise false. | ||
|
||
`ifgt <value1> <value2>` - return true when `<value1>` is greater than `<value2>`, otherwise false. | ||
|
||
`ifge <value1> <value2>` - return true when `<value1>` is greater than or equal to `<value2>`, otherwise false. | ||
|
||
`ifle <value1> <value2>` - return true when `<value1>` is less than or equal to `<value2>`, otherwise false. | ||
|
||
## Commands with side effects | ||
|
||
`ifdefs <name> <variable> <newvalue>` - return true when a variable with name `<name>` is defined, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
`ifndefs <name> <variable> <newvalue>` - return true when a variable with name `<name>` is not defined, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
`ifeqs <value1> <value2> <variable> <newvalue>` - return true when `<value1>` is equal to `<value2>`, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
`ifnes <value1> <value2> <variable> <newvalue>` - return true when `<value1>` is not equal to `<value2>`, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
`iflts <value1> <value2> <variable> <newvalue>` - return true when `<value1>` is less than `<value2>`, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
`ifgts <value1> <value2> <variable> <newvalue>` - return true when `<value1>` is greater than `<value2>`, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
`ifges <value1> <value2> <variable> <newvalue>` - return true when `<value1>` is greater than or equal to `<value2>`, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
`ifles <value1> <value2> <variable> <newvalue>` - return true when `<value1>` is less than or equal to `<value2>`, otherwise false. If the statement is true, `<variable>` will be set to `<newvalue>`. | ||
|
||
## Special Commands | ||
|
||
`else` - used in a block to define an alternative output when no statement in the block is truthy. | ||
|
||
`end` - used to end a block. |
8 changes: 8 additions & 0 deletions
8
docs/versioned_docs/version-0.4.x/development/_category_.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "🛠️ Development", | ||
"position": 9, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Contribute to the development of the project", | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
# Development | ||
|
||
1. clone this repo | ||
2. run `npm install` | ||
3. run `npm run build:watch` | ||
4. run `node out/index.js` |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
# Roadmap | ||
- [x] no-template option | ||
- [x] include data from other files | ||
- [x] include data from urls | ||
- [x] support mutliple files as input | ||
- [ ] custom markers | ||
- [ ] possibility to reference variables inside JavaScript expressions |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "✨ Examples", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Examples" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Basic | ||
|
||
*Example: test.txt* | ||
``` | ||
foobar | ||
$[if `1 + 2 == 4`]$ | ||
a | ||
$[ifeq foo bar]$ | ||
b ${{foo}}$ | ||
$[else]$ | ||
c | ||
$[end]$ | ||
${{`0.1 + 0.2`}}$ | ||
${{file:incl.txt}}$ | ||
${{url:https://httpbin.org/uuid}}$ | ||
${{env:HOME}}$ | ||
``` | ||
*and incl.txt:* `This was included from incl.txt` | ||
|
||
Running this example with `utpp test.txt foo=bar` will result in the following output: | ||
``` | ||
foobar | ||
b bar | ||
0.30000000000000004 | ||
This was included from incl.txt | ||
{ | ||
"uuid": "ba95cd1c-2bb9-4a54-a1a4-5379ce1f2fac" | ||
} | ||
/home/adrian | ||
``` |
8 changes: 8 additions & 0 deletions
8
docs/versioned_docs/version-0.4.x/getting-started/_category_.json
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "🚀 Getting Started", | ||
"position": 2, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Getting started" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
docs/versioned_docs/version-0.4.x/getting-started/blocks.mdx
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
# Blocks | ||
|
||
A (template) block can be declared by using one or more `$[<command>]$` statements where `<command>` is a valid command (see API reference below) and must end in a `$[end]$` statement. | ||
|
||
A block's statements are evaluated from top to bottom. If the result of a command is truthy, the guarded section will be outputted and all other commands in this block ignored. | ||
|
||
Otherwise this statement will be skipped and the next statement is evaluated. If no statement in this block is truthy, the `else` section will be outputted and if no `else` section is present, nothing will be outputted. | ||
|
||
There can be any number of blocks declared in a file, but blocks **cannot** be nested. |
7 changes: 7 additions & 0 deletions
7
docs/versioned_docs/version-0.4.x/getting-started/commands.mdx
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
|
||
# Commands | ||
A command generally follows this syntax `$[<name> [arg1] [arg2] ... [argN]]$` | ||
where `<name>` is a [command's name](#commands-reference) `[arg]` is a [*Value*](#values). All commands return either `true` or `false`. |
11 changes: 11 additions & 0 deletions
11
docs/versioned_docs/version-0.4.x/getting-started/how-it-works.mdx
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# How it works | ||
|
||
```mermaid | ||
graph LR; | ||
a(Read file)-->b[Apply template]-->c[Apply variables]-->e(Write file); | ||
``` |
Oops, something went wrong.