如何创建动态URL与流星? [英] How do I create dynamic URL's with Meteor?

查看:110
本文介绍了如何创建动态URL与流星?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我新的Web开发,并通过在流星的现场演示交口称赞,并想使用它。我只用谷歌应用程序引擎,到目前为止并在主类来处理动态URL我会写这样的事:

I'm new to web dev and was blown away by the demo on Meteor's site and would like to use it. I've only used Google App Engine so far and to handle a dynamic URL in the main class I would write something like this:

app = webapp2.WSGIApplication([('/[0-9]', HandlePost)], debug=True)

这将任何网址与数字0到9月末到处理程序类,会与使用模板引擎的网页,如把手适当的数据加载HTML页面映射。

This would map any URL's with the numbers 0 through 9 at the end to a handler class that would load an HTML page with the appropriate data for a page using a templating engine such as handlebars.

我该怎么做类似的东西在流星?

How do I do something similar in Meteor?

推荐答案

使用骨干路由器,请参阅:
http://backbonejs.org/#Router-routes 结果
对于像你的例子正则表达式看:
<一href=\"http://blog.rjzaworski.com/2011/12/regex-routing-with-backbone-js/\">http://blog.rjzaworski.com/2011/12/regex-routing-with-backbone-js/

试用待办事项例子上的流星,请参阅客户端/ todo.js 文件:

Use backbone's router, see: http://backbonejs.org/#Router-routes
For regexps like your example see: http://blog.rjzaworski.com/2011/12/regex-routing-with-backbone-js/
Try out the todo example on meteor, see the client/todo.js file:

////////// Tracking selected list in URL //////////

var TodosRouter = Backbone.Router.extend({
  routes: {
    "todo_list/:list_id": "main"
  },
  main: function (list_id) {
    Session.set("list_id", list_id);
    Session.set("tag_filter", null);
  },
  setList: function (list_id) {
    this.navigate("todo_list/"+list_id, true);
  }
});

Router = new TodosRouter;

Meteor.startup(function () {
  Backbone.history.start({pushState: true});
});

这篇关于如何创建动态URL与流星?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆