mirror of
https://git.sakamoto.pl/laudom/http.sh.git
synced 2025-08-15 09:51:04 +02:00
Compare commits
2 commits
f2d72ef6ee
...
ec0238f76f
Author | SHA1 | Date | |
---|---|---|---|
|
ec0238f76f | ||
|
be23e31362 |
2 changed files with 19 additions and 0 deletions
|
@ -155,3 +155,15 @@ This is very useful when creating menus; Instead of relying on hardcoded values,
|
||||||
on *the same URI level*, one can create links such as `<a href="{{-uri-2}}meow">(...)</a>`, which will always
|
on *the same URI level*, one can create links such as `<a href="{{-uri-2}}meow">(...)</a>`, which will always
|
||||||
resolve to the same file; This eliminates a whole class of bugs where trailing slashes would break some
|
resolve to the same file; This eliminates a whole class of bugs where trailing slashes would break some
|
||||||
poorly-written relative URLs.
|
poorly-written relative URLs.
|
||||||
|
|
||||||
|
## Set statement
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| In the template | `{{-set-<name>}}` |
|
||||||
|
| In the code | n/a |
|
||||||
|
| Notes | Very simple, processed out of order, nesting in conditional statements will not work. |
|
||||||
|
|
||||||
|
If `{{-set-<name>}}` exists anywhere within your processed template (including the included templates),
|
||||||
|
`array[?<name>]` will get set internally. This can be used to conditionally enable parts of another template
|
||||||
|
based on what other templates are loaded.
|
||||||
|
|
|
@ -38,6 +38,13 @@ function render() {
|
||||||
buf+="${subtemplate}"
|
buf+="${subtemplate}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# process special set statements
|
||||||
|
if [[ "$template"$'\n'"$garbage" == *'{{-set-'* ]]; then
|
||||||
|
while read key; do
|
||||||
|
ref["?$key"]=_
|
||||||
|
done <<< "$(grep -Poh '{{-set-\K(.*?)(?=}})' <<< "$template")"
|
||||||
|
fi
|
||||||
|
|
||||||
local key
|
local key
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for key in ${!ref[@]}; do
|
for key in ${!ref[@]}; do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue