Created
March 12, 2016 01:00
-
-
Save markmo/71fc668207b2f9cb2e4d to your computer and use it in GitHub Desktop.
TemplateHelper
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
/* | |
* Alternative implementation using a Custom Interpolator. | |
* | |
* @param sc StringContext | |
*/ | |
implicit class TemplateHelper(val sc: StringContext) extends AnyVal { | |
def t(args: Any*): String = { | |
val strings = sc.parts.iterator | |
val expressions = args.iterator | |
val sb = new StringBuilder(strings.next) | |
while (strings.hasNext) { | |
sb append expressions.next | |
sb append strings.next | |
} | |
sb.toString | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment