[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [MirageOS-devel] using cow
On 23 Dec 2013, at 11:59, Richard Mortier <Richard.Mortier@xxxxxxxxxxxxxxxx> wrote: > i'm having a few issues using cow to recreate mirage-decks and wonder whether > i'm missing something really obvious. code at > <http://github.com/mor1/mirage-decks>. > > each slideshow on decks is served up using reveal.js which itself ends up > using an in-browser markdown renderer to render slides from markdown > fragments between <section></section> tags. > > at the moment, each deck is in its own directory containing an (incomplete) > index.html file which contains the slides as <section /> fragments plus all > the images referred to. when a deck is requested i then read the relevant > index.html file in, and insert it into a template which is an <:html< ... >> > fragment. > > it's this insertion that's causing me problems. if i insert into the template > as the anti-qutoation $str:deck$ then all the html in deck is escaped (< > becomes < etc). obviously this doesn't render correctly. if i read in the > index.html and parse it, then i can insert as $deck$ and that works but it's > meant i've needed to do a fair amount of tidying up of the index.html files > for all the slide decks to get past cow's parser. > > so-- is there a way to say "just insert this string verbatim" in a quotation > (or anti-quotation or whatever the things between $$ are called in cow)? You can't insert the string verbatim, as the type of the $$ must be a Cow.Xml.t. The whole point of $str:$ is to take care of escaping. However, you should be able to just parse the template fragment into Cow.Xml.t and insert it as such. I'm guessing it doesn't parse because of... > fwiw i've had similar issues with literal js between <script> </script> tags > which i've overcome by pulling it out into a file and then serving that > appropriately. i could probably do something similar here by just having the > template as html fragments that are manually prepended/appended, but that > feels like a kludge -- given that type-checking is good, being able to > typecheck the template as valid html, even if i can't type-check the entire > page, seems a good thing... :) And here you hit the biggest drawback with Cow's parser: the $ anti-quotations mean that there's no way to escape them (that I know of). So if you have: <:html< <script> var foo = $bar; </script> >> You need insert the dollar without typing it in. I use this: let d = [`Data "$"] <:html< <script> var foo = $d$bar; </script> >> Alternatively, you could make it valid XHTML by wrapping it in a CDATA. <:html< //<![CDATA[ <script> var foo = $bar; </script> //]]> >> The latter is probably the best solution, since we serve the MIME type as XHTML anyway. -anil _______________________________________________ MirageOS-devel mailing list MirageOS-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |