Skip to content

Instantly share code, notes, and snippets.

@coltborg
Last active April 20, 2023 18:14
Show Gist options
  • Save coltborg/a0242c9b217b9c61aa050f41be35d999 to your computer and use it in GitHub Desktop.
Save coltborg/a0242c9b217b9c61aa050f41be35d999 to your computer and use it in GitHub Desktop.
Update fragment call in templates to use `~{}` syntax. First change file path to templates you want to affect.
#!/bin/sh
search_dir="/Users/alexgonzalez/Desktop/Code/form-flow/src/test/resources/templates"
# for each file in search directory and subdirectories, do the following
find "$search_dir" -type f -name "*.html" | while read file; do
sed -n '
/\(fragments.*\)"/ {
s/\(fragments.*\)"/~{\1}"/g
p
s/.*//
h
}
!/\(fragments.*\)"/ {
H
$!d
}
$ {
p
}
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment