UNPKG

l-html

Version:

An HTML Generation Library for Javascript

34 lines (30 loc) 919 B
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script src="../dist/l.js"></script> <script> class Profile { constructor(name, age, phoneNumber) { this.name = name; this.age = age; this.phoneNumber = phoneNumber; } editAge(e) { alert('Call me at ' + this.phoneNumber); } render(parent) { return l(parent, l.with({ this:this }, () => div( h1(`Welcome, ${this.name}!`), ul(li(`Age: ${this.age}`), li(`Phone Number: ${this.phoneNumber}`, { onclick: this.editAge.bind(this) }) ), ))); } } </script> </body> </html>