mausch / XmlLiteralsTypeProvider

F# type provider implementing compile-time XML literals
Apache License 2.0
5 stars 2 forks source link

Include template #6

Open mausch opened 10 years ago

mausch commented 10 years ago

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.

panesofglass commented 10 years ago

Would this be similar to the idea of partials? Would you be able to nest to an arbitrary depth?

panesofglass commented 10 years ago

How would you deal with the concept of layouts? Could that also be an include? Would it require an alternative include pattern?

mausch commented 10 years ago

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.