Skip to content

Instantly share code, notes, and snippets.

@alextea
Last active April 6, 2016 13:47
Show Gist options
  • Save alextea/12ecab18cc3ebebb86fe7064e4801fa1 to your computer and use it in GitHub Desktop.
Save alextea/12ecab18cc3ebebb86fe7064e4801fa1 to your computer and use it in GitHub Desktop.
Regular expressions for converting mustache to nunjucks
# template tag
\{\{<([^}]+)\}\}
{% extends "$1.html" %}
# includes tag
\{\{>([^}]+)\}\}
{% include "$1.html" %}
# block tag
\{\{\$([^}]+)\}\}
{% block $1 %}
# for loops and if conditionals
\{\{#([^}]+)\}\}
{% for i in $1 %}
{% if $1 %}
# if false conditionals
\{\{\^([^}]+)\}\}
{% if $1 != true %}
# closing tags
\{\{/[^}]+\}\}
{% endblock %}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment