Created
December 11, 2016 19:04
-
-
Save jcleveley-zz/7656bf9d733f85f71d04fb7bd9f1aa52 to your computer and use it in GitHub Desktop.
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
#! /bin/zsh | |
autoload -U zmv | |
zmv -C '(**/)(*).mustache' '$1$2.html' | |
for file in **/*.html; do | |
echo "Converting: $file"; | |
# Comments | |
perl -0777 -pi -e 's/{{\!(.*?)}}/{#$1#}/s' $file | |
# Partials | |
perl -pi -e 's/{{> ?(\S+) ?}}/{% include "$1.html" %}/g' "$file" | |
# Block | |
perl -pi -e 's/{{#([^}]+)}}/{% if $1 %}/g' "$file" | |
# End block | |
perl -pi -e 's/{{\/[^}]+}}/{% endif %}/g' "$file" | |
# No html escape | |
perl -pi -e 's/{{{ ?(\S+) ?}}}/{{ $1|safe }}/g' "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment