addyosmani / addyosmani/page-router

consider combining with <url-route>

Abierto
#1 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
CSS
Estrellas
16
Forks
1
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hello, I wrote [``](https://github.com/codemix/url-route) which does some pretty similar stuff to ``. It would be nice to combine them. The two libraries take some different approaches:
1. `` is focussed on conditionally displaying elements, so you can do something like this:

``` html


I will only be displayed when the page fragment is

#wat




```

Whereas `` is all about declaring routes and then emitting events. It would be possible to support a similar use case in ``:

``` html


```

``` js
document.addEventListener('route-changed', function (route) { });
// or
document.addEventListener('route:wat', function (route) { });
```
2. `` uses director.js whereas `` rolls its own with a syntax stolen from the Yii php framework.

``` html

```

vs

``` html


```

Personally I like ours better (of course :smile:) simply because afaik director.js does not support the definition of named patterns inline (e.g. specifying that `id` in the example above can only be an integer). It appears that director.js's approach is to declare those special cases ahead of time which I think is inconvenient here. Also i'm unsure whether director's approach works with real URLs (`pushState` etc), and not just fragment based ones, whereas this works with both. It's nice if you're already using director of course, but most apps probably aren't.

WDYT?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.