addyosmani / addyosmani/page-router

consider combining with <url-route>

Đang mở
#1 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
CSS
Star
16
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.