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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const DictionaryValue* json, | 43 const DictionaryValue* json, |
44 const base::StringPiece& template_id); | 44 const base::StringPiece& template_id); |
45 | 45 |
46 // The following functions build up the different parts that the above | 46 // The following functions build up the different parts that the above |
47 // templates use. | 47 // templates use. |
48 | 48 |
49 // Appends a script tag with a variable name |templateData| that has the JSON | 49 // Appends a script tag with a variable name |templateData| that has the JSON |
50 // assigned to it. | 50 // assigned to it. |
51 void AppendJsonHtml(const DictionaryValue* json, std::string* output); | 51 void AppendJsonHtml(const DictionaryValue* json, std::string* output); |
52 | 52 |
| 53 // Same as AppendJsonHtml(), execpt does not include the <script></script> |
| 54 // tag wrappers. |
| 55 void AppendJsonJS(const DictionaryValue* json, std::string* output); |
| 56 |
53 // Appends the source for JsTemplates in a script tag. | 57 // Appends the source for JsTemplates in a script tag. |
54 void AppendJsTemplateSourceHtml(std::string* output); | 58 void AppendJsTemplateSourceHtml(std::string* output); |
55 | 59 |
56 // Appends the code that processes the JsTemplate with the JSON. You should | 60 // Appends the code that processes the JsTemplate with the JSON. You should |
57 // call AppendJsTemplateSourceHtml and AppendJsonHtml before calling this. | 61 // call AppendJsTemplateSourceHtml and AppendJsonHtml before calling this. |
58 void AppendJsTemplateProcessHtml(const base::StringPiece& template_id, | 62 void AppendJsTemplateProcessHtml(const base::StringPiece& template_id, |
59 std::string* output); | 63 std::string* output); |
60 | 64 |
61 // Appends the source for i18n Templates in a script tag. | 65 // Appends the source for i18n Templates in a script tag. |
62 void AppendI18nTemplateSourceHtml(std::string* output); | 66 void AppendI18nTemplateSourceHtml(std::string* output); |
63 | 67 |
64 // Appends the code that processes the i18n Template with the JSON. You | 68 // Appends the code that processes the i18n Template with the JSON. You |
65 // should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling | 69 // should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling |
66 // this. | 70 // this. |
67 void AppendI18nTemplateProcessHtml(std::string* output); | 71 void AppendI18nTemplateProcessHtml(std::string* output); |
68 | 72 |
69 } // namespace jstemplate_builder | 73 } // namespace jstemplate_builder |
70 #endif // CHROME_COMMON_JSTEMPLATE_BUILDER_H_ | 74 #endif // CHROME_COMMON_JSTEMPLATE_BUILDER_H_ |
OLD | NEW |