[Ur] PATCH: add inlineScript directive
austin seipp
as at hacks.yi.org
Wed Sep 21 19:49:00 EDT 2011
Hi Adam, sorry for taking so long to get back to this issue.
On Sun, Sep 4, 2011 at 2:41 PM, Adam Chlipala <adamc at impredicative.com> wrote:
> This is very similar to functionality requested before on this list, for
> including stylesheets within applications. Perhaps the right solution is a
> generic mechanism for including static files? That would certainly make it
> easy to avoid dealing with issues that come from concatenating JavaScript
> source files together.
I'd agree. The two main things people want here are JavaScript and CSS
I'd suppose. The boilerplate can roughly be put down to something like
this (Zachary Tatlock put this trick on the list earlier):
val inlineStuff = "..."
fun retStuff () = retBlob (textBlob inlineStuff) (blessMime "text/css")
...
<link type="text/css" href={url (retStuff ())}/>
I notice there is no 'script' tag in basis. This makes it not possible
to use this trick for JavaScript, hence why I went the route of
modifying the compiler. Although I assume it could be added quite
easily, so kinda moot point.
Perhaps there should be another top-level declaration for 'static'
files, which declare values of a new 'static' type or somesuch?
Something like:
static cssCode
static jsCode
...
<script type="text/javascript" href={staticUrl cssCode}/>
<link type="text/css" href={staticUrl jsCode}/>
with accompanying .urp declarations like:
staticFile Module.cssCode=static/style.css text/css
staticFile Module.jsCode=static/extra.js text/javascript
etc...
The above is sort of half-baked but I think you get the idea. The new
'static' type could have functions to get the accompanying
mime/url/blob etc. The URL could effectively be generated by the
compiler, (perhaps just app.timestamp.1.js, app.timestamp.2.js,
app.timestamp.1.css, etc,) it doesn't really matter as long as you can
get at it I'd say. This would probably be a little more modular, since
you also won't risk final applications having static files which
override each other with similar/equivalent names, etc.
FWIW, the Opa compiler does something like this basically, where it
compiles all static assets into the resulting binary and gives you a
single executable. They do this for CSS/JavaScript/images etc, but I
think just CSS/JS are fine for most purposes at the moment. Perhaps
only a restricted subset of MIME types should be allowed.
--
Regards,
Austin
More information about the Ur
mailing list