Skip to content

Instantly share code, notes, and snippets.

@psychobunny
Created May 3, 2014 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psychobunny/b73bbc98ce540c1f99fc to your computer and use it in GitHub Desktop.
Save psychobunny/b73bbc98ce540c1f99fc to your computer and use it in GitHub Desktop.
Converting HBS to templates.js syntax

Use this in a text editor that supports regex search (like Sublime Text)

Find all

\{\{#if ([\S]*)\}\}([\s\S]*?)\{\{else\}\}([\s\S]*?)\{\{/if\}\}

Replace With

<!-- IF $1 -->$2<!-- ELSE -->$3<!-- ENDIF $1 -->

Find All

\{\{#if ([\S]*)\}\}([\s\S]*?)\{\{/if\}\}

Replace With

<!-- IF $1 -->$2<!-- ENDIF $1 -->

Find All

\{\{\#each ([\S]*)\}\}([\s\S]*?)\{\{\/each\}\}

Replace With

<!-- BEGIN $1 -->$2<!-- END $1 -->

Find All

\{\{\{([\S]*?)\}\}\}

Replace With

{$1}

Find All

\{\{([\S]*?)\}\}

Replace With

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