quiki icon indicating copy to clipboard operation
quiki copied to clipboard

model variable type inference

Open cooper opened this issue 7 years ago • 2 comments

I think we can fairly reliably infer whether variables in models are strings or booleans. If it is displayed anywhere, it is a string. If it is used in a conditional but not displayed, it is a boolean. Keep in mind that strings can be tested in conditionals too, so string inference overrides boolean.

later this can be used in frontends to make forms for model data: img_9693

cooper avatar Apr 29 '17 01:04 cooper

with maps and lists, this would be way more complicated, especially when the wikifier language has a foreach construct ...but still possible.

cooper avatar May 06 '17 20:05 cooper

what if, instead, you could optionally specify the variables the model looks for?

@model.title:     Social button;
@model.author:    Mitchell Cooper;
@model.params: {
    link: { type: text; required: yes; desc: Link target; };
    icon: { type: text; desc: Font Awesome icon name; };
};

format { <a href="[@link]"><i class="fa fa-[@icon]"></i></a> }

Notice the @m prefix is gone. Wouldn't need it when args are provided, since the parser would know which variables should be available to the model.

cooper avatar Mar 28 '20 23:03 cooper