justinhunt / moodle-filter_generico

Generic Filter
9 stars 11 forks source link

Nesting Generico Templates #34

Open a-kempka opened 1 year ago

a-kempka commented 1 year ago

Is there a possibility to nest/reference a Generico template inside another Generico template? The goal is to reduce reduntant text by grouping text blocks (that are templates) into one template that unites the text.

One could have a main template e.g. a table. The cells of the table would be populated with text from other templates. Alternatively: could templates themselves be passed as a variable to a Generico template?

justinhunt commented 1 year ago

You should be able to nest Generico templates now on the page. But putting Generico tags in the a Generico template itself probably wont work. And I think it would be very difficult. We do plan to redo Generico to use Mustache templates (when?) and at that time we might be able to nest tags elegantly

a-kempka commented 1 year ago

Thank you for your quick reply. Using Mustache in the future would be nice as it would give template designers more control over the content while using a standardized/familiar syntax.

a-kempka commented 1 year ago

Is there any documentation on how to nest/reference one template in another? So far having an outer template with a call to an inner template results in just showing the inner template's name:

outer_template: Here's an example {GENERICO:type="inner_template"}

inner_template: Example 1

Calling {GENERICO:type="outer_template"} Results in Generico printing: {GENERICO:type="inner_template"} not in printing Example 1

justinhunt commented 1 year ago

you can not nest a template in another templates definition. Because that text is not filtered. It just shows it as is. You would have to nest on the page that will be saved and shown to the user. eg

{GENERICO:type=tabs} {GENERICO:type=tabitem}blah blah blah {GENERICO:type=tabitem_end} {GENERICO:type=tabs_end}

I know thats not really what you had in mind though.