如何从另一个渲染组件/助手? [英] How to render component/helper from another one?

查看:84
本文介绍了如何从另一个渲染组件/助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有render-component( source ),用于从控制器字段渲染组件/帮助器。它对于ember 1.9.1但在更新到ember之后工作正常1.12.1我发现API中有更改。在更新代码之后,我可以恢复简单的情况(比如通过某些属性的名称渲染视图)。但功能的最大部分仍然破裂。

I have render-component ( source ) which used to render components/helpers from controller fields. It worked fine for ember 1.9.1 but after updating up to ember 1.12.1 I found changes in API. After updating code I restore simple cases ( like render view by name from some property ). But largest part of functionality still broken.

我有兴趣在哪里可以阅读更多关于这样的事情,如

I'm interesting about where can I read more about such things like


  • env(使用内部组件/帮助程序内部实现)

  • env ( which used inside components/helpers internal implementation )

变形(我知道这是html-bar的一部分,对于更多的文档感兴趣)

morph ( I understand that it's a part of html-bars, but I'm interested in more documentation )

任何人都可以分享一些经验在创造这样的帮手?或者在这种情况下找到解决方案? (我的意思是这些东西没有完全记录)

Can anyone share some experience at creating such helper ? Or way to find solution in such cases? ( I mean that this things not fully documented )

我知道从ember 1.11的组件助手,但它不允许渲染助手(使用参数)并使用它我应该定义模板中的所有属性。当组件/助手的名称是动态的时候,我应该传递不同的参数/属性。

P.S. I know about component-helper from ember 1.11 -- but it doesn't allow render helpers ( with params) and using it I should define all properties in template. And when name of component/helper is dynamic -- I should pass different params / attributes.

提前提前

PPS

我想要帮助我恢复的功能的一些例子(更多的例子和动机,你可以在帮助页面找到 - 我只是想要笔记的差异,我的帮手和build-in component-helper):

Some examples of functionality I want restore with my helper ( more examples and motivation you can find at helper page -- I just want note difference between my helper and build-in component-helper ):

{{#render-component componentName _param='btn-component' action="addSection"}}
{{render-component 'pluralize-component' ___params=hash}} // hash = { count:ungrouped.content.meta.total, single:"Object"}
{{#render-component 'componentName' _param=paramName someOption=someOptionValue}}


推荐答案

你在这里有很多问题,但是要回答你的题目:Ember 1.11介绍了组件助手,允许您动态渲染组件。

You've got quite a few questions here, but to answer the one in your title: Ember 1.11 introduced the component helper that allows you to dynamically render components.

componentName: 'someComponentName'

...

{{component componentName param=value someAction='someMapping'}}

这篇关于如何从另一个渲染组件/助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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