Created
July 18, 2012 13:08
-
-
Save mlrawlings/3136120 to your computer and use it in GitHub Desktop.
HTML insert before tag (strings)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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