marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.4k stars 644 forks source link

Nested tags only work one level deep #167

Closed ashishcpatel2 closed 8 years ago

ashishcpatel2 commented 8 years ago

I have a marko tag with the following marko-tag.json:

{
    "@class" : "string",
    "@items <item>[]": {
        "@wallpaper <wallpaper>": {
            "@class": "string"
        },
        "@panel <panel>": {
            "@class": "string"
        },
        "@someProp": "string"
    }
}

And the following index.js:

module.exports = require('marko-widgets').defineComponent({
    template: require('./template.marko.html'),
    getTemplateData: function(state, input) {
        input.items = input.items || [];
        var items = [];

        for (var i = 0; i < items.length; i++) {
            var item = items[i];

            var wallpaper = (item.wallpaper || {renderBody:''}).renderBody;
            var panel = (item.panel || {renderBody:''}).renderBody;
            var someProp = item.someProp || 'default';

            items.push({
                wallpaper: wallpaper,
                panel: panel,
                someProp: someProp
            });
        }
        return {
            items: items
        };
    }
});

Attempting to use it in the following way doesn't seem to work:

<img-carousel>
  <img-carousel.item someProp="someValue" for="item in data.items">
    <img-carousel.item.wallpaper>
      <img alt="${item.img.alt}" src="${item.img.src}">
    </img-carousel.item.wallpaper>
    <img-carousel.item.panel>
      <p if="item.text">$!{item.text}</p>
    </img-carousel.item.panel>
  </img-carousel.item>
</img-carousel>
patrick-steele-idem commented 8 years ago

Hey @ashishcpatel2, thanks for reporting the issue. I'm not going to have a chance this weekend to take a look, but I'll take a closer tomorrow. I'll update you as soon as I know more. Thanks again.

patrick-steele-idem commented 8 years ago

Hey @ashishcpatel2, just wanted to provide an update that I was able to reproduce the problem and I have added a test case. It looks like things almost worked, but there is a bug in the taglib loader that is preventing the deeply nested tags from being properly registered. I am still investigating to see what is required to be changed to support deeply nested tags.

patrick-steele-idem commented 8 years ago

Hey @ashishcpatel2, I pushed a fix to allow nested tags to be arbitrarily deep.

New version of marko published: marko@2.7.31

Thanks for your patience. Please let us know if you run into any other issues. Thanks for your help.