[PATCH 5 of 6 json-style] templates: add json style

Gregory Szorc gregory.szorc at gmail.com
Wed Dec 31 16:45:35 CST 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# 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


More information about the Mercurial-devel mailing list