Open mausch opened 10 years ago
Would this be similar to the idea of partials? Would you be able to nest to an arbitrary depth?
How would you deal with the concept of layouts? Could that also be an include? Would it require an alternative include pattern?
Yes, it would allow arbitrary nesting, though there has to be a limit or some sort of checking to prevent cyclic references (which would mean non-terminating compilation without any hint about it! Maybe I can include compiler messages about things being included).
IMHO "partial views" are a very ad-hoc, unnecessary concept. They're just a function (most of the time parameterized) returning an XElement.
Layouts are an unnecessary concept as well, they're just a simple template with some holes, i.e a function taking some parameters (holes) and returning a XElement or XDocument.
With XElement composition, most of the concepts of "view engines" simply disappear: models become regular parameters/arguments and views/partials/layouts/helpers are just functions.
Add a
<x:include file="..."/>
element to embed a template inside another. The resulting template would include all the holes found in the embedded template.