Code Monkey home page Code Monkey logo

Comments (14)

Sivli-Embir avatar Sivli-Embir commented on May 21, 2024

👍 Trying to create a form with dynamic inputs components. What is the reason Template.dynamic does not work? I can't even get normal templates to render inside a component.

from meteor-blaze-components.

mitar avatar mitar commented on May 21, 2024

Normal components should work inside a component. So if you want to include a normal component that should work well. But it is true that I do not have a test case for that. Feel free to make one. :-)

The other way, it does not work because components are not templates. They just use templates for content. So when you do Template.dynamic you are in fact including just the raw template content, not the component.

from meteor-blaze-components.

Sivli-Embir avatar Sivli-Embir commented on May 21, 2024

Odd, it was not working for me. May be a bug related to #30 I will review.

from meteor-blaze-components.

offthegrass avatar offthegrass commented on May 21, 2024

@Kestanous please post your findings. Did you get anywhere with using FlowLayout as a component? (#19)

from meteor-blaze-components.

Sivli-Embir avatar Sivli-Embir commented on May 21, 2024

@offthegrass I am actually fighting off a head cold so I am only responding to issue today. I will try to investigate more on all points tomorrow, assuming I can thing again.

from meteor-blaze-components.

mitar avatar mitar commented on May 21, 2024

Now you can simply use Template.dynamic and pass component's name as a template argument. And it will use the component.

But a disclaimer. Often it is better that instead of using Template.dynamic to create a method on the current component which is returning such a dynamic value. So that you move this logic into the component. Then somebody else can later on extend/override it in subclasses.

So instead of doing:

{{> Template.dynamic template=foo}}

You could do:

class FooComponent extends BlazeComponent
  renderFoo: ->
    BlazeComponent.getComponent(@data().foo).renderComponent @currentComponent()
{{> renderFoo}}

from meteor-blaze-components.

rclai avatar rclai commented on May 21, 2024

Wait a minute, I tried passing the register'd name of the component to Template.dynamic. It rendered, but it has no access to the component's methods at all.

from meteor-blaze-components.

mitar avatar mitar commented on May 21, 2024

I have this in tests. And tests work. So I am not sure what is happening here? Can you get a reproduction going on? Or adding/modifying tests so that they fail in the same way you are observing?

from meteor-blaze-components.

rclai avatar rclai commented on May 21, 2024

Sorry about that, Meteor's shell was messing with me.

from meteor-blaze-components.

pward123 avatar pward123 commented on May 21, 2024

How do I pass args to the renderComponent call? i.e.

{{> renderFoo args blah=1}}

from meteor-blaze-components.

mitar avatar mitar commented on May 21, 2024

You cannot, this is a limitation I do not know how to go around: #12.

from meteor-blaze-components.

rclai avatar rclai commented on May 21, 2024

@mitar, when you do this:

class FooComponent extends BlazeComponent
  renderFoo: ->
    BlazeComponent.getComponent(@data().foo).renderComponent @currentComponent()

Does that render the component while inheriting the instance properties of the @currentComponent()?

from meteor-blaze-components.

mitar avatar mitar commented on May 21, 2024

No, it sets current component as parent component. So you can access it and its properties through @componentParent(). You can also do that in the handlebars {{componentParent.bla}}.

from meteor-blaze-components.

rclai avatar rclai commented on May 21, 2024

Gotcha thanks.

from meteor-blaze-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.