Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: chrome/common/jstemplate_builder.h

Issue 11929016: Move jstemplate_builder.* to ui\webui so it can be reused by webui implementations outside of chrom… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to 177705 to get yfriendman's fix Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/descriptors_android.h ('k') | chrome/common/jstemplate_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
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
12
13 #ifndef CHROME_COMMON_JSTEMPLATE_BUILDER_H_
14 #define CHROME_COMMON_JSTEMPLATE_BUILDER_H_
15
16 #include <string>
17
18 #include "base/string_piece.h"
19
20 namespace base {
21 class DictionaryValue;
22 }
23
24 namespace jstemplate_builder {
25
26 // While an object of this class is in scope, the template builder will output
27 // version 2 html. Version 2 uses load_time_data.js and i18n_template2.js, and
28 // should soon become the default.
29 class UseVersion2 {
30 public:
31 UseVersion2();
32 ~UseVersion2();
33
34 private:
35 DISALLOW_COPY_AND_ASSIGN(UseVersion2);
36 };
37
38 // A helper function that generates a string of HTML to be loaded. The
39 // string includes the HTML and the javascript code necessary to generate the
40 // full page with support for JsTemplates.
41 std::string GetTemplateHtml(const base::StringPiece& html_template,
42 const base::DictionaryValue* json,
43 const base::StringPiece& template_id);
44
45 // A helper function that generates a string of HTML to be loaded. The
46 // string includes the HTML and the javascript code necessary to generate the
47 // full page with support for i18n Templates.
48 std::string GetI18nTemplateHtml(const base::StringPiece& html_template,
49 const base::DictionaryValue* json);
50
51 // A helper function that generates a string of HTML to be loaded. The
52 // string includes the HTML and the javascript code necessary to generate the
53 // full page with support for both i18n Templates and JsTemplates.
54 std::string GetTemplatesHtml(const base::StringPiece& html_template,
55 const base::DictionaryValue* json,
56 const base::StringPiece& template_id);
57
58 // The following functions build up the different parts that the above
59 // templates use.
60
61 // Appends a script tag with a variable name |templateData| that has the JSON
62 // assigned to it.
63 void AppendJsonHtml(const base::DictionaryValue* json, std::string* output);
64
65 // Same as AppendJsonHtml(), except does not include the <script></script>
66 // tag wrappers.
67 void AppendJsonJS(const base::DictionaryValue* json, std::string* output);
68
69 // Appends the source for JsTemplates in a script tag.
70 void AppendJsTemplateSourceHtml(std::string* output);
71
72 // Appends the code that processes the JsTemplate with the JSON. You should
73 // call AppendJsTemplateSourceHtml and AppendJsonHtml before calling this.
74 void AppendJsTemplateProcessHtml(const base::StringPiece& template_id,
75 std::string* output);
76
77 // Appends the source for i18n Templates in a script tag.
78 void AppendI18nTemplateSourceHtml(std::string* output);
79
80 // Appends the code that processes the i18n Template with the JSON. You
81 // should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling
82 // this.
83 void AppendI18nTemplateProcessHtml(std::string* output);
84
85 } // namespace jstemplate_builder
86 #endif // CHROME_COMMON_JSTEMPLATE_BUILDER_H_
OLDNEW
« no previous file with comments | « chrome/common/descriptors_android.h ('k') | chrome/common/jstemplate_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698