cooper / quiki

a file-based web engine and server featuring a productive source language, markdown, image generation, categories, templates, and revision tracking
https://quiki.app
ISC License
30 stars 8 forks source link

model variable type inference #20

Open cooper opened 7 years ago

cooper commented 7 years ago

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 commented 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.

cooper commented 4 years ago

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.