-
Notifications
You must be signed in to change notification settings - Fork 1
Pages
MohammadAli Arjomand edited this page Aug 26, 2023
·
2 revisions
You can create a page via singlighter
node singlighter make:page HomePage
Pages will creating in ~/Scripts/Pages
template
is a required method in every pages. In template
you must return HTML codes as string
class HomePage extends Page {
template() {
return "<h1>Hello, SinglightJs!</h1>";
}
}
setup
is a optional method in pages. setup
will running before loading page (no reloading)
class HomePage extends Page {
template() {
return "<h1>Hello, SinglightJs!</h1>";
}
setup() {
console.log("Hi there!");
}
}
With this.route
you can use route parameters
For example, in this route
router.addRoute("/posts/{id}", PostShowPage);
You can access to id
value by this.route.id
class PostShowPage extends Page {
template() {
return "<h1>Post Show</h1>";
}
setup() {
console.log(this.route.id);
}
}
MIT License, Copyright (c) 2023 MohammadAli Arjomand