Patchwork [5,of,6,json-style] templates: add json style

mail settings
Submitter Gregory Szorc
Date Dec. 31, 2014, 10:45 p.m.
Message ID <8a88b921f7b9b4670464.1420065935@gps-mbp.local>
Download mbox | patch
Permalink /patch/7291/
State Changes Requested
Headers show


Gregory Szorc - Dec. 31, 2014, 10:45 p.m.
# HG changeset patch
# User Gregory Szorc <>
# Date 1420063134 28800
#      Wed Dec 31 13:58:54 2014 -0800
# Node ID 8a88b921f7b9b467046496ab6aa99d2589dd935c
# Parent  850bab749730a01b318ff100858c06fa87c8d78e
templates: add json style

We add a "json" style that uses the previously-introduced jsonengine to
render templates to JSON.

Unlike existing templates, our custom engine with its default
serialization behavior for unknown templates doesn't require the
definition of each and every template. Instead, our style basically says
"render JSON for everything." If we add a new template in the future, we
don't have to update the style!

As upcoming tests will demonstrate, this style is not yet perfect. It
will be refined in the patches ahead.


diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
new file mode 100644
--- /dev/null
+++ b/mercurial/templates/json/map
@@ -0,0 +1,2 @@ 
+mimetype = 'application/json'
+defaultengine = json