Skip to content
Lauri Rooden edited this page May 25, 2021 · 1 revision

Methods

View.def(definitions)

Define views hierarchy in form:

route file-needed.js,another-file.css
users/{user} users.view,%.css

Path Expansion can be used to define files.

View.get(url, params)

Find a matching view, assign parameters from url to params and return View object

View.show(url)

Find a matching view and call show on it

View.param(name, callback)

Add callback to resolve url parameters. Name can be a string or array of strings.

View.param(["user", "post"], function(value, name, params) {
	api(name).get(value, function(err, item) {
		if (err) return View("404").show()
		El.data.model = item
	})
	.then(this.wait())
})
// Optional path for views, default = ""
View.base = "/js/views/"

// Define starting point in DOM
View("body", document.body)

// Default view
View.main = "home"