OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This provides some helper methods for building and rendering an | 5 // This provides some helper methods for building and rendering an |
6 // internal html page. The flow is as follows: | 6 // internal html page. The flow is as follows: |
7 // - instantiate a builder given a webframe that we're going to render content | 7 // - instantiate a builder given a webframe that we're going to render content |
8 // into | 8 // into |
9 // - load the template html and load the jstemplate javascript into the frame | 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 | 10 // - given a json data object, run the jstemplate javascript which fills in |
11 // template values | 11 // template values |
12 | 12 |
13 #ifndef CHROME_COMMON_JSTEMPLATE_BUILDER_H_ | 13 #ifndef CHROME_COMMON_JSTEMPLATE_BUILDER_H_ |
14 #define CHROME_COMMON_JSTEMPLATE_BUILDER_H_ | 14 #define CHROME_COMMON_JSTEMPLATE_BUILDER_H_ |
15 #pragma once | 15 #pragma once |
16 | 16 |
17 #include <string> | 17 #include <string> |
18 | 18 |
| 19 #include "base/string_piece.h" |
| 20 |
19 namespace base { | 21 namespace base { |
20 class DictionaryValue; | 22 class DictionaryValue; |
21 class StringPiece; | |
22 } | 23 } |
23 | 24 |
24 namespace jstemplate_builder { | 25 namespace jstemplate_builder { |
25 | 26 |
26 // A helper function that generates a string of HTML to be loaded. The | 27 // A helper function that generates a string of HTML to be loaded. The |
27 // string includes the HTML and the javascript code necessary to generate the | 28 // string includes the HTML and the javascript code necessary to generate the |
28 // full page with support for JsTemplates. | 29 // full page with support for JsTemplates. |
29 std::string GetTemplateHtml(const base::StringPiece& html_template, | 30 std::string GetTemplateHtml(const base::StringPiece& html_template, |
30 const base::DictionaryValue* json, | 31 const base::DictionaryValue* json, |
31 const base::StringPiece& template_id); | 32 const base::StringPiece& template_id); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // Appends the source for i18n Templates in a script tag. | 66 // Appends the source for i18n Templates in a script tag. |
66 void AppendI18nTemplateSourceHtml(std::string* output); | 67 void AppendI18nTemplateSourceHtml(std::string* output); |
67 | 68 |
68 // Appends the code that processes the i18n Template with the JSON. You | 69 // Appends the code that processes the i18n Template with the JSON. You |
69 // should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling | 70 // should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling |
70 // this. | 71 // this. |
71 void AppendI18nTemplateProcessHtml(std::string* output); | 72 void AppendI18nTemplateProcessHtml(std::string* output); |
72 | 73 |
73 } // namespace jstemplate_builder | 74 } // namespace jstemplate_builder |
74 #endif // CHROME_COMMON_JSTEMPLATE_BUILDER_H_ | 75 #endif // CHROME_COMMON_JSTEMPLATE_BUILDER_H_ |
OLD | NEW |