mausch / XmlLiteralsTypeProvider

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

Real XElement tree? #5

Open mausch opened 10 years ago

mausch commented 10 years ago

At the moment, Render() parses the string xml template each time, then does the replacements in-place. I wonder if it's possible to generate the real XElement tree as a static field instead, then render by operating on it without modifying it.

panesofglass commented 10 years ago

Should be possible. Couldn't you use Linq to XML to apply the values during render?

panesofglass commented 10 years ago

Would this mean you could add additional modifications, such as find all script tag references and generate a minified bundle replacement?

mausch commented 10 years ago

It already uses Linq to XML (ReplaceWith) to apply the values during render, not sure what you meant.

It's also already possible to find script tag references, either after rendering or by getting the raw template parsed as XElement which would be easy to implement.

This issue aims to implement actual XML literals like VB.NET, i.e. compiling a XML source to something like:

static val __template : XElement =
    XElement("html", XElement("head", ...

Even though the current implementation is compile-time checked, technically it's not a XML literal. Also, it means that currently the XML tree has to be parsed both at compile-time to create the hole parameters, and then at run-time to render with the hole values. It would make sense to only parse it at compile-time.

panesofglass commented 10 years ago

@mausch I hadn't looked at the source, so I wasn't sure how you were parsing it. I'll RTFC first next time :8ball: