Skip to content

Instantly share code, notes, and snippets.

@mlrawlings
Created July 18, 2012 13:08
Show Gist options
  • Save mlrawlings/3136120 to your computer and use it in GitHub Desktop.
Save mlrawlings/3136120 to your computer and use it in GitHub Desktop.
HTML insert before tag (strings)
insertBeforeTag = (html, tag, toInsert) ->
pos = html.indexOf(tag);
return html if pos != -1
return html.slice(0, pos) + toInsert + html.slice(pos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment