Add ICU message format support
[chromium-blink-merge.git] / ui / base / webui / jstemplate_builder.h
blob875a18599571a67c19684ca4b1c4db8596e5466c
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This provides some helper methods for building and rendering an
6 // internal html page. The flow is as follows:
7 // - instantiate a builder given a webframe that we're going to render content
8 // into
9 // - load the template html and load the jstemplate javascript into the frame
10 // - given a json data object, run the jstemplate javascript which fills in
11 // template values
13 #ifndef UI_BASE_WEBUI_JSTEMPLATE_BUILDER_H_
14 #define UI_BASE_WEBUI_JSTEMPLATE_BUILDER_H_
16 #include <string>
18 #include "base/strings/string_piece.h"
19 #include "ui/base/ui_base_export.h"
21 namespace base {
22 class DictionaryValue;
25 namespace webui {
27 // A helper function that generates a string of HTML to be loaded. The
28 // string includes the HTML and the javascript code necessary to generate the
29 // full page with support for i18n Templates.
30 UI_BASE_EXPORT std::string GetI18nTemplateHtml(
31 const base::StringPiece& html_template,
32 const base::DictionaryValue* json);
34 // A helper function that generates a string of HTML to be loaded. The
35 // string includes the HTML and the javascript code necessary to generate the
36 // full page with support for both i18n Templates and JsTemplates.
37 UI_BASE_EXPORT std::string GetTemplatesHtml(
38 const base::StringPiece& html_template,
39 const base::DictionaryValue* json,
40 const base::StringPiece& template_id);
42 // Assigns the given json data into |loadTimeData|, without a <script> tag.
43 UI_BASE_EXPORT void AppendJsonJS(const base::DictionaryValue* json,
44 std::string* output);
46 } // namespace webui
48 #endif // UI_BASE_WEBUI_JSTEMPLATE_BUILDER_H_