[PATCH 12 of 20] hgweb, paper: add shortlogajax template and use it

Alexander Plavin alexander at plav.in
Tue Aug 13 03:44:05 CDT 2013

13.08.2013, 12:30, "Martin Geisler" <martin at geisler.net>:
> Alexander Plavin <alexander at plav.in> writes:
>>  [...] the rendered, complete html code is sent as a CDATA section, and
>>  js just has to add it to the page.
> Please ignore this if it's obvious to you, but remember that you need to
> escape "]]>" in CDATA sections:
>   http://en.wikipedia.org/wiki/CDATA#Uses_of_CDATA_sections
> You will probably have to unescape this again on the client side?
> In other words, using CDATA isn't really different from using normal
> escaping of "<" and "&", it just feels that way because you (typically)
> get to escape fewer characters.

Heh, it's true of course, but there can't occur such character sequence (as I understand). The content of the CDATA section is just HTML markup with correct tags and all the special characters in text (e.g. cset description) escaped.

> Another thought that occured to me when I read the discussion about
> writing an XML style: have you considered writing a JSON style instead?
> That might be even more useful for JavaScript code.

In this application (I mean infinite scrolling) json style doesn't give any differences/benefits to xml one, as we would have to render the templates in JS anyway. The only difference for future uses in javascript is using xfr.responsexml vs json.parse(xfr.responsetext). So, this variants are about equivalent and one of them just has to be chosen.
However, I don't know what will be best here, and would like to hear more opinions on this.

> Other applications might benefit from such a style too, even on the
> command line where I would prefer to parse JSON encoded 'hg log' output
> over XML output. That of course depends on whether JSON or XML has
> better support in the environment where you work.
> --
> Martin Geisler

More information about the Mercurial-devel mailing list