Freak613 / domc

DOM compiler
MIT License
215 stars 11 forks source link

[Q] How do we add conditional HTML or domc components? #8

Open trsh opened 5 years ago

trsh commented 5 years ago

Could not find any examples.

update: scope => {
        return {
            someCond: scope.localVar === 'me' ? 'yes' : 'no'
        }
    },

This is just variable change.

trsh commented 5 years ago

Something like this?

domc.component("input-title", {
    create: scope => {
      return {};
    },
    update: scope => {
      return {
        html: scope.showControl() ? `<div class="input-title">{{ input.name }}</div>` : ``
      };
    },
    template: `{{ html }}`
  });
Freak613 commented 5 years ago

Not like that. The library missing v-if directive for now and doesn't support node replacing, allowing only insert it at first render.

trsh commented 5 years ago

@Freak613 should be high priority :)

kokujin commented 5 years ago

Any news on this?

Freak613 commented 5 years ago

Not so. I'll update ticket once implemented.

rozek commented 1 year ago

I've just proposed a sketch of a possible implementation of a v-if directive as a separate issue which might be of help...