Skip to content

Instantly share code, notes, and snippets.

@joeriks
Last active December 26, 2015 01:29
Show Gist options
  • Save joeriks/7071285 to your computer and use it in GitHub Desktop.
Save joeriks/7071285 to your computer and use it in GitHub Desktop.
Sample creating HTML in code in Typescript
module HTML {
export function elem(tag:string, content:string){
return "<" + tag + ">" + content + "</" + tag + ">"
}
export function div(inner:string[]){
return elem("div",inner.join(""))
}
export function p(content:string){
return elem("p",content)
}
}
module HTML.views {
export var home =
div([
p("First para"),
p("Second para")
])
}
document.body.innerHTML=HTML.views.home