{"id":16918614,"url":"https://github.com/martinkolarik/ractive-route","last_synced_at":"2025-03-22T11:30:46.961Z","repository":{"id":18179440,"uuid":"21293627","full_name":"MartinKolarik/ractive-route","owner":"MartinKolarik","description":"Routing library for Ractive.js","archived":false,"fork":false,"pushed_at":"2023-11-14T21:04:27.000Z","size":246,"stargazers_count":37,"open_issues_count":0,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-03-14T18:15:12.340Z","etag":null,"topics":["javascript","ractive-components","ractivejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MartinKolarik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-06-28T01:28:49.000Z","updated_at":"2024-01-14T12:44:04.000Z","dependencies_parsed_at":"2023-11-14T22:23:38.617Z","dependency_job_id":"e787d7ee-e0e3-4933-95f1-003b88fadc92","html_url":"https://github.com/MartinKolarik/ractive-route","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinKolarik%2Fractive-route","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinKolarik%2Fractive-route/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinKolarik%2Fractive-route/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinKolarik%2Fractive-route/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MartinKolarik","download_url":"https://codeload.github.com/MartinKolarik/ractive-route/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244951097,"owners_count":20537319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","ractive-components","ractivejs"],"created_at":"2024-10-13T19:40:48.791Z","updated_at":"2025-03-22T11:30:46.110Z","avatar_url":"https://github.com/MartinKolarik.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ractive-route\n\nSimple routing library for Ractive.js with support for two way (model \u003c-\u003e URI) data binding.\n\n[See it in action!](http://rawgit.com/MartinKolarik/ractive-route/master/demo/index.html) ([source](https://github.com/MartinKolarik/ractive-route/tree/master/demo))\n\n## Get started\n\n```\nhttps://cdn.jsdelivr.net/npm/ractive-route@0.3.7/ractive-route.min.js\n```\n\nractive-route will always expose itself as `Ractive.Router`. Additionally, you can load it using AMD or CommonJS module loader.\n\n## API\n\n### new Router(options)\n\n**options** `Object`:\n\n**el** `HTMLElement|string|jQuery-like collection`\n\n`el` that will be passed to your Ractive components.\n\n**data** `function`\n\nA function that will be invoked every time a new component is created and the returned data will be passed to your component.\n\n**basePath** `string` (default: `''`)\n\nPath to your application.\n\n**history** `Object` (default: `window.history`)\n\nCustom History API to use. It has to implement `pushState()` and `replaceState()` methods.\n\n**strictMode** `boolean` (default: `false`)\n\nIf set to `false`, URLs are case insensitive and starting and trailing slashes are ignored.\n\n**reloadOnClick** `boolean` (default: `false`)\n\nIf set to `true`, clicking on a link will always force a `dispatch()`.\n\n### addRoute(pattern, Handler[, observe])\n\n**pattern** `string`\n\nCan contain required or optional variables:\n\n```\n/users/:id/ - required\n/users/:id?/ - optional\n```\n\nBy default, every variable will match anything except `/`. You can specify a pattern for each variable if you want:\n\n```\n/users/:id(\\d+)/\n/users/:id(\\d+)?/\n```\n\n**Handler** `function`\n\nRactive component or function to handle the requests.\n\n**Observe** `Object`\n\nThis object can contain one or more of the following properties:\n\n- `qs` - a list of keys that will be observed and synced with query string.\n- `hash` - a list of keys that will be observed and synced with hash.\n- `state` - a list of keys that will be observed and synced with the History API.\n\n### dispatch(request[, options])\n\nDispatch the `request` to the first `route` matching the `request`. If there is no such route, redirect to the requested URI.\n\n**request** `string`\n\nEither a relative or an absolute URI.\n\n**options** `Object`:\n\n**reload** `boolean` (default: `false`)\n\nIf set to `false`, then the request will be dispatched only if there is a difference between the new and the current URI.\n\n**noHistory** `boolean` (default: `false`)\n\nIf set to `false`, then `replaceState()` will be used instead of `pushState()`.\n\n**qs** `Object`\n\nAdditional query string data. These two lines will do exactly the same:\n\n```js\nrouter.dispatch('/users/123/?search=a');\nrouter.dispatch('/users/123/', { qs: { search: 'a' } });\n```\n\n**hash** `Object`\n\nAdditional hash data. These two lines will do exactly the same:\n\n```js\nrouter.dispatch('/users/123#!{\"search\":\"a\"}');\nrouter.dispatch('/users/123/', { hash: { search: 'a' } });\n```\n\n**state** `Object`\n\nState data that will be passed to `pushState()` function.\n\n### getUri()\n\nReturns a current URI relative to `basePath`.\n\n### init(options)\n\nA shorthand for:\n\n```js\nrouter.dispatch(router.getUri(), { noHistory: true });\n```\n\n### match(request)\n\nReturns a first `route` matching the `request` or `null`.\n\n### watchLinks([pattern])\n\nWatch all links that don't have `router-ignore` class and match the `pattern` and perform `dispatch()` on `click`. The default `pattern` matches all internal links.\n\n**pattern** `RegExp` (default: `new RegExp('^((https?:)?\\\\/\\\\/' + location.hostname.replace(/\\./g, '\\\\.') + '.*|((?!\\\\/\\\\/)[^:]+))$');`)\n\n### unwatchLinks()\n\nStop listening to `click` events.\n\n### watchState()\n\nPerform `dispatch()` on `popstate`.\n\n### unwatchState()\n\nStop listening to `popstate` events.\n\n## License\nCopyright (c) 2014 - 2017 Martin Kolárik. Released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinkolarik%2Fractive-route","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinkolarik%2Fractive-route","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinkolarik%2Fractive-route/lists"}