Created
August 22, 2019 14:51
-
-
Save nottrobin/2f0c6690421eadecc82c4b2cbc1182cc to your computer and use it in GitHub Desktop.
Convert Django templates' `{% include with ... %}` syntax to Jinja2's `{% with ... %}{% include %}{% endwith %}`
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
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; | |
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\",\n \$4=\"\$5\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; | |
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\",\n \$4=\"\$5\",\n \$6=\"\$7\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; | |
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\",\n \$4=\"\$5\",\n \$6=\"\$7\",\n \$8=\"\$9\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; | |
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\",\n \$4=\"\$5\",\n \$6=\"\$7\",\n \$8=\"\$9\",\n \$10=\"\$11\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; | |
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\",\n \$4=\"\$5\",\n \$6=\"\$7\",\n \$8=\"\$9\",\n \$10=\"\$11\",\n \$12=\"\$13\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; | |
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\",\n \$4=\"\$5\",\n \$6=\"\$7\",\n \$8=\"\$9\",\n \$10=\"\$11\",\n \$12=\"\$13\",\n \$14=\"\$15\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; | |
find templates -name '*.html' -exec perl -p -i -e "s/ *[{]% +include +\"(.*)[\"'] +with +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] +([^=]+)=[\"']([^\"]*)[\"'] *%[}]/{% with \$2=\"\$3\",\n \$4=\"\$5\",\n \$6=\"\$7\",\n \$8=\"\$9\",\n \$10=\"\$11\",\n \$12=\"\$13\",\n \$14=\"\$15\",\n \$16=\"17\" %}\n {% include \"\$1\" %}\n{% endwith %}/" {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment