Skip to content

Instantly share code, notes, and snippets.

@rpowis
Created August 19, 2016 15:16
Show Gist options
  • Save rpowis/b6da2ce2c553ebe42457aa2439f2455e to your computer and use it in GitHub Desktop.
Save rpowis/b6da2ce2c553ebe42457aa2439f2455e to your computer and use it in GitHub Desktop.
Convert mustache/hogan templates to nunjucks.
#### REPLACE LAYOUTS
{{<layouts(.*)}}((.|\n)*){{\/(.*)}}
replace with
{% extends "$1.html" %} $2
#### REPLACE BLOCK TITLES
{{\$(\w+)}}
((.|\n)*)
{{\/(\w+)}}
replace with
{% block $1 %} \r $2 \r {% endblock %}
#### REPLACE INCLUDES
{{>(.*)}}
replace with
{% include "$1.html" %}
#### IF TRUE
{{#(.*)}}((.|\n)*){{\/(.*)}}
replace with
{% if $1 %} \r $2 \r {% endif %}
#### IF NOT TRUE
{{\^(.*)}}((.|\n)*){{\/(.*)}}
replace with
{% if not $1 %} \r $2 \r {% endif %}
@pietrodesiato
Copy link

You can use the regular expressions in Sublime. You'll to enable the Regex by clicking on the ".*" option in the 'Search and Replace' screen.

screen shot 2016-08-19 at 16 19 57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment