peerlibrary / meteor-blaze-components

Reusable components for Blaze
http://components.meteorapp.com/
BSD 3-Clause "New" or "Revised" License
354 stars 26 forks source link

Minimum working configuration for package-based architecture #78

Closed brajt closed 9 years ago

brajt commented 9 years ago

First of all, thank you for the great package. I'm using it since my first days with Meteor and don't imagine working without it. But lately I'm trying to rewrite my code into packages and somehow fail to make Blaze Components working. I'm pretty sure there's something trivial missing in the following code that I tried to make as basic as possible.

Let's take a standard packages structure for Meteor. Package.js in brajt:lib uses and implies some basic packages. Package.js in brajt:core uses and implies brajt:lib, takes care of routing and adds two files:

Layout.tpl.jade

p Does it work? #{test}

Layout.coffee

Template.layout.helpers:
  test: ->
    'Yes!'

At this moment, everything is working properly.

I add peerlibrary:blaze-components@0.13.0 package to brajt:lib and in brajt:core, replace Layout.coffee with LayoutComponent.coffee:

class LayoutComponent extends BlazeComponent
  @register 'Layout'

  test: ->
    'Yes!'

This time, the text in helper doesn't show up. Of course it works fine in standard architecture without packages. I tried to fix it by some random changes, such as adding namespace Brajt.LayoutComponent and exporting it, but I didn't solve the problem. I've read somewhere in the issues or documentation that Components are exported by default and there's no need to do that by myself.

So the question as in the title: what is the minimum working configuration for using Blaze Components in package-oriented Meteor app?

mitar commented 9 years ago

Your template is named layout, but your component Layout. Case sensitivity matters.

mitar commented 9 years ago

(It would be really helpful if you would publish a concrete example, a reproduction.)

brajt commented 9 years ago

I tried it with both layout and Layout. I will provide the full reproduction.

mitar commented 9 years ago

Yes. For such examples it is really important to have a full reproduction because it is probably really some small detail. I am using Blaze Components in many packages without problems.

brajt commented 9 years ago

https://github.com/brajt/blaze-components-test

I've never worked with Meteor packages on Github before, so I didn't know if I should create separate repositories for brajt:lib and brajt:core. Well, at least you can see the full code now.

Thanks a lot for help!

mitar commented 9 years ago

BlazeLayout.render 'layout' does not render a Blaze Component, but normal Blaze template.

You can use the following Layout for Blaze Components: https://gist.github.com/offthegrass/3c1491cc9d5b4c5cb5d0

brajt commented 9 years ago

Hmm now that's interesting, as it works perfectly fine when not in a package and I used it for last two months without problems. Thanks a lot, I'll check out your solution immediately.