Skip to content

Commit

Permalink
updated docs and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
husixu1 committed Mar 18, 2024
1 parent 634b010 commit df7fc03
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,28 @@ BPT employs a straightforward grammar whereby any content beyond the top-level d

## Examples

### Variable Replacement
### Variable Modding

```
{{var}}
{{var or "abc"}} # Use "abc" if var is empty
{{var or {{var2}}}} # Use {{var2}} if var is empty
{{var :- "abc"}} # Alias to {{var or "abc"}}
{{var and "abc"}} # Use "abc" if var is not empty
{{var and {{var2}}}} # Use {{var2}} if var is not empty
{{var :+ "abc"}} # Alias to {{var and "abc"}}
{{var :? "Err msg"}} # Abort rendering when varaible is empty
{{var % "*:"}} # Remove prefix until first ':'
{{var %% "*:"}} # Remove prefix until last ':'
{{var # ":*"}} # Remove suffix from last ':'
{{var ## ":*"}} # Remove suffix from first ':'
{{var ^}} # Uppercase the first character
{{var ^^}} # Uppercase all characters
{{var ,}} # Lowercase the first character
{{var ,,}} # Lowercase all characters
```

Bash internal variables can also be used:
Expand Down Expand Up @@ -224,12 +238,14 @@ QUOTE -> ld quote cl ARGS rd .
ARGS -> ARGS STMT
| STMT .
VAR -> ld ID rd
| ld ID or VAR rd
| ld ID or STR rd
| ld ID and VAR rd
| ld ID and STR rd .
BOP -> ne | eq | gt | lt | ge | le
| strne | streq | strgt | strlt | strcm .
| ld ID MOD rd
| ld ID MOD VAR rd
| ld ID MOD STR rd .
MOD -> and | or | err
| pfx | ppfx | sfx | ssfx
| upp | uupp | low | llow .
BOP -> ne | eq | gt | lt | ge | le
| strne | streq | strgt | strlt | strcm .
UOP -> ex .
ID -> id .
STR -> str .
Expand Down
10 changes: 8 additions & 2 deletions bpt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,16 @@ bpt.print_help() {
echo " bpt -l \"<<\" -r \">>\" g input.tpl > output.sh"
echo
echo -e "\033[1mTEMPLATE GRAMMAR EXAMPLES\033[0m"
echo " Variable replacements"
echo " Variable modding"
echo ' {{ var }}'
echo ' {{ var or "abc" }}'
echo ' {{ var or {{var2}} }}'
echo ' {{ var %% {{var2}} }}'
echo
echo ' Available modifiers are: '
echo ' replacement: and or :- :+ '
echo ' non-empty: :?'
echo ' pre/suf-fix: ## # %% %'
echo ' upper/lower: ^^ ^ ,, ,'
echo
echo " Branching"
echo ' {{ {{x}}: {{var1}} : {{var2}} }}'
Expand Down

0 comments on commit df7fc03

Please sign in to comment.