Open cooper opened 7 years ago
with maps and lists, this would be way more complicated, especially when the wikifier language has a foreach construct ...but still possible.
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.
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: