Skip to content

Instantly share code, notes, and snippets.

@binary1230
Last active July 10, 2016 16:28
Show Gist options
  • Save binary1230/cf2cf5bca6842d691931ff9c9b90f867 to your computer and use it in GitHub Desktop.
Save binary1230/cf2cf5bca6842d691931ff9c9b90f867 to your computer and use it in GitHub Desktop.
regexes to match ubersystem jinja template conversion
\{% (options) ([^\s]+) ([^\s]+) \%\}
{{ $1\($2,$3\) }}
\{\% (popup_link) (".*?") (".*?") \%\}
{{ macros.$1\($2,$3\) }}
\{\% (checkgroup) (.*)\.(.+) \%\}
{{ $2.html_$1('$3') }}
# can improve this by copying from yesno example
\{\{ (.+?(?=|))default:"" }}
{{ $1default('') }}
\{\{ (.+?(?=|))(datetime):(".*?") \}\}
{{ $1$2($3) }}
\{\{ (.+?(?=|))(yesno):(".*?") \}\}
{{ $1$2($3) }}
\{\% (checkbox) (.*)\.(.+) \%\}
{{ macros.$1($2, '$3') }}
# catch anything like: whatever|tag:"stuff" turn into whatever|tag("stuff"), also works for single quoted
\{\{ (.+?(?=|))(.*?):(["'].*?["'])
\{\{ $1$2($3)
\{% (stripe_form) ([^\s]+) ([^\s]+) \%\}
{{ $1\('$2',$3\) }}
\{\% (stripe_button) (".*?") \%\}
\{\{ macros.$1\($2\) \}\}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment