Giter VIP home page Giter VIP logo

Comments (5)

jackhorton avatar jackhorton commented on September 22, 2024

Another use case for this actually has intermediate-template in a loop, so it is actually called as <intermediate-template w-id="items[]" />, even though we never actually use items[x], only items[x]-subwidget-id. That use case is a bit more complex but could be tied to the same underlying process. I don't have any opinion one way or another on giving the intermediate template a w-id, but I would just like to be able to save on shipping down widget code if nothing will use it.

from marko-widgets.

patrick-steele-idem avatar patrick-steele-idem commented on September 22, 2024

Hi @jackhorton, it seems reasonable that you might want to break up a UI component into multiple templates (hopefully within the single directory for the UI component). It seems pretty doable to support this, I'm going to need to take a closer look to get a better idea of the scope of work. I know it will require some changes to the compile-time transform that we are using to process the Marko template files, but I don't think the work is too much. I'll send an update soon. Thanks for opening the Github issue.

from marko-widgets.

patrick-steele-idem avatar patrick-steele-idem commented on September 22, 2024

New version published with enhancement: [email protected]

from marko-widgets.

patrick-steele-idem avatar patrick-steele-idem commented on September 22, 2024

Hi @jackhorton, please let me know if things work as expected with the latest code that now allows w-id to be used in an intermediate template for a UI component. I have added a test case that validates the new functionality. Thanks.

from marko-widgets.

jackhorton avatar jackhorton commented on September 22, 2024

This works, though not entirely as expected. Given my second example, where the intermediate template is called in a loop, we may want to namespace it a bit.

Given a container.marko as such...

<div w-bind>
    <intermediate-template w-id="group[]" />
</div>

... with everything else the same as in my original post, every single widget-*.marko is added directly to the group[] array. Even if we give the sub-widgets a declared w-id, it gets overwritten. So, in this example, the ids on the page turn out as follows: w0, w0-group[0], w0-group[1], w0-group[2], w0-group[3], rather than what I was expecting, w0, w0-group[0]-widget-one, w0-group[0]-widget-two, w0-group[0]-widget-three, w0-group[0]-maybe-this-has-a-really-special-id. Perhaps the worse problem is that if intermediate-template is given a non-array w-id, it still overwrites them all, but then you just have a bunch of nodes with "w0-group" as each one's ID, which will cause issues.

So, the way that it exists now, at least in the array implementation, isn't really a problem for us, because we can still call getWidgets("group") on the container and get every widget south of it, which is what we are using it for. I guess the concern is that it will silently overwrite assigned w-ids on sub-widgets, and in the process would break getWidget() functionality. I have not determined what would happen if there was another sub-sub-widget in one of the sub-widgets, but i would imagine it also just gets added to the array.

from marko-widgets.

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.