Last active
December 29, 2015 17:39
-
-
Save mausch/7706117 to your computer and use it in GitHub Desktop.
Draft/pseudocode for HTML type provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/mausch/status/406420573518970880 | |
// compiles to ModelLayout -> XElement where ModelLayout = { title: string; script: XAttribute; bodyAttrs: XAttribute list; body: XElement } | |
type Layout = HTML<""" | |
<html> | |
<head> | |
<title><x:text id="title"/></title> | |
<script x:attr="script"></script> | |
</head> | |
<body x:attrs="bodyAttrs"> | |
<x:elem id="body"/> | |
</body> | |
</html> | |
"""> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I realized that what I actually want is XML literals. I really don't care about non-XML HTML so I just use the System.Xml.Linq parser. I just started implementing it here: https://github.com/mausch/XmlLiteralsTypeProvider
After implementing holes for elements/attributes, it would be very interesting to be able to read templates from a file. That way, you'd keep templates in a file, which anyone could edit outside of a development environment but any changes to its holes would affect compilation as it should.