Mithril 2.0.3

buildPathname(object)


Description

Turns a path template and a parameters object into a string of form /path/user?a=1&b=2

var querystring = m.buildPathname("/path/:id", {id: "user", a: "1", b: "2"})
// "/path/user?a=1&b=2"

Signature

querystring = m.buildPathname(object)

Argument Type Required Description
object Object Yes A key-value map to be converted into a string
returns String A string representing the input object

How to read signatures


How it works

The m.buildPathname creates a path name from a path template and a parameters object. It's useful for building URLs, and it's what m.route, m.request, and m.jsonp all use internally to interpolate paths. It uses m.buildQueryString to generate the query parameters to append to the path name.

var querystring = m.buildPathname("/path/:id", {id: "user", a: 1, b: 2})

// querystring is "/path/user?a=1&b=2"

License: MIT. © Leo Horie.