Meteor的火焰和Famo.us如何一起玩? [英] How do Meteor's blaze and Famo.us play together?

查看:101
本文介绍了Meteor的火焰和Famo.us如何一起玩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2技术:


  • 流星与闪耀模板引擎

  • Famo.us与他们的令人敬畏的gui框架

我来自流星边,我个人喜欢用{{mustache}}(把手)来驱动gui数据,反应式会话/数据库使这真正高效和直观。

I come from the meteor side, I personally like using {{mustache}} (handlebars) to drive the gui from data, the reactive session / database makes this really efficient and intuitive.

现在来了famo.us及其所有优点,但基于代码的gui的缺点是那里不再是车把的地方...

Now came famo.us and all its advantages, but the drawback of a code based gui is that there is no place for handlebars anymore…


  • 将这两种技术混合在一起的现行做法是什么?

  • 它们是完全分离的吗?

  • 使用观察/Deps.autorun机制是一个常见的做法,在一个由流星反应项更新的famo.us元素?

推荐答案

我刚刚发布了 famous-components ,whi ch是Blaze和Famous之间紧密整合的尝试。到目前为止,我见过的所有其他方法都是Blaze的大部分步骤,并且需要在JavaScript中编写大量代码,这在Meteor中对我来说感觉非常不自然。流星代码应该小巧,简洁,易于获得强大的结果。下面是一些示例:(每个模板形成一个renderNode,任何HTML都放在Surface上。修饰符/视图/选项被指定为组件属性)

I just released a preview of famous-components, which is an attempt at a tight integration between Blaze and Famous. All the other approaches I've seen so far side step most of Blaze, and require writing large amounts of code in JavaScript, which felt very unnatural to me in Meteor. Meteor code should be small, concise and easy with powerful results. Here are a few examples of what it looks like: (each template forms a renderNode, any HTML gets put on a Surface. Modifiers/views/options are specified as a component attributes)

<template name="test">
  {{#Surface size=reactiveSizeHelper}}
    <p>hello there</p>
  {{/Surface}}

  {{#if loggedIn}}
    {{>SequentialLayout template='userBar' direction="X"}}
  {{else}}
    {{>Surface template='pleaseLogIn' origin="[0.5,0.5]"}}
  {{/if}}
</template>

Scrollview(可拆分为子模板):

Scrollview (can be split into sub templates):

<template name="famousInit">
  {{#Scrollview size="[undefined,undefined]"}}
    {{#famousEach items}}
      {{#Surface size="[undefined,100]"}}{{name}}{{/Surface}}
    {{/famousEach}}
  {{/Scrollview}}
</template>

Template.famousInit.items = function() { return Items.find() };

事件:

Template.blockSpring.events({
  'click': function(event, tpl) {
    var fview = FView.fromTemplate(tpl);
    fview.modifier.setTransform(
      Transform.translate(Math.random()*500,Math.random()*300),
      springTransition
    );
  }
});

它也可以用铁路由器装箱。更多细节,文档,现场演示,全部以
http://famous-views.meteor.com/

It also works out the box with iron-router. More details, docs, live demos, all at http://famous-views.meteor.com/

这篇关于Meteor的火焰和Famo.us如何一起玩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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