Skip to content

Instantly share code, notes, and snippets.

@chirino
Forked from jstrachan/gist:2035806
Created March 14, 2012 11:12
Show Gist options
  • Save chirino/2035817 to your computer and use it in GitHub Desktop.
Save chirino/2035817 to your computer and use it in GitHub Desktop.
kotlin code: "foo $a bar $b"
by default is turned into...
StringTemplate(array("foo ", " bar"), array(a, b))
if a custom compiler plugin knew you wanted a Html template, say, it could change that code to
MyHtmlTemplate(a, b)
with this class being generated:
class MyHtmlTemplate(a: String, b: Foo) : HtmlTemplate {
fun toString() = "foo " + a + " bar " + b
fun toHtml(out: Appender, format: HtmlFormat): Unit {
out.append("foo ")
format.append(out, a)
out.append(" bar ")
format.append(out, b)
out.append(" bar ")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment