Skip to content

Instantly share code, notes, and snippets.

@trueadm
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trueadm/c3d6977b34ced80ae9b4 to your computer and use it in GitHub Desktop.
Save trueadm/c3d6977b34ced80ae9b4 to your computer and use it in GitHub Desktop.
DOM DSL Example #1
template() {
return [
div => [
header => [
h1 => ["Example " + this.title]
]
],
div => ["#main",
$if => [this.todos.length > 0,
div => [
span => [".counter", "There are " + this.todos.length + " todos!"]
]
],
ul => [".todos",
$forEach => [this.todos, (todo, index) =>
li => ['.todo',
h2 => ["A todo!"],
span => [index + ": " + todo]
]
]
],
form => [{id: this.formId, method: "post", action: "#"},
div => [".form-control",
input => [{name: "first_name", type: "text"}]
],
button => [{type: "submit", onClick: this.click},
"Submit!"
]
]
]
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment