Skip to content

Instantly share code, notes, and snippets.

@slaveofcode
Forked from etiennemarais/regex.md
Created November 22, 2017 03:35
Show Gist options
  • Save slaveofcode/9f3bc8ba96070f09ee5daf5a56ac4e18 to your computer and use it in GitHub Desktop.
Save slaveofcode/9f3bc8ba96070f09ee5daf5a56ac4e18 to your computer and use it in GitHub Desktop.
Regular expression for handlebars variables, includes, if/else blocks and unescaped variables

Regex

{{[{]?(.*?)[}]?}}

Captures the value of the variable name in a handlebars template

{{> components/templates/email/includes/email-tr-spacer }}
{{# deliveryAddress }}
{{^ deliveryAddress }}
{{{ deliveryAddressReadable }}}
{{/ deliveryAddress }}
{{/ contactNumber }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment