summaryrefslogtreecommitdiffstats
path: root/chrome/common/jstemplate_builder.h
diff options
context:
space:
mode:
authorarv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 00:40:25 +0000
committerarv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 00:40:25 +0000
commit7cd22a5102842cfbb51e06c626d769d81bb78210 (patch)
tree3a4ba627dc1589201cdb659d2aaa0d99c78111ed /chrome/common/jstemplate_builder.h
parent76f565227a89e88b6a0a32bf36cc5c01f6e418ca (diff)
downloadchromium_src-7cd22a5102842cfbb51e06c626d769d81bb78210.zip
chromium_src-7cd22a5102842cfbb51e06c626d769d81bb78210.tar.gz
chromium_src-7cd22a5102842cfbb51e06c626d769d81bb78210.tar.bz2
This provides a simpler js template engine than JsTemplate. It has been
optimized for the way we do internationalization with JST before and is about 4 times faster (average 4.8ms vs 22.8ms) for the history page. The syntax for this is very similar to JsTemplates. It uses the attributes i18n-values and i18n-content which worls like jsvalues and jscontent except that it does not allow arbitrary expressions. BUG=None TEST=All UI pages should work as before Review URL: http://codereview.chromium.org/149420 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/jstemplate_builder.h')
-rw-r--r--chrome/common/jstemplate_builder.h50
1 files changed, 44 insertions, 6 deletions
diff --git a/chrome/common/jstemplate_builder.h b/chrome/common/jstemplate_builder.h
index 6d3d8d0..e1861d2 100644
--- a/chrome/common/jstemplate_builder.h
+++ b/chrome/common/jstemplate_builder.h
@@ -19,11 +19,49 @@ class DictionaryValue;
class StringPiece;
namespace jstemplate_builder {
- // A helper function that generates a string of HTML to be loaded. The
- // string includes the HTML and the javascript code necessary to generate the
- // full page.
- std::string GetTemplateHtml(const StringPiece& html_template,
- const DictionaryValue* json,
- const StringPiece& template_id);
+
+// A helper function that generates a string of HTML to be loaded. The
+// string includes the HTML and the javascript code necessary to generate the
+// full page with support for JsTemplates.
+std::string GetTemplateHtml(const StringPiece& html_template,
+ const DictionaryValue* json,
+ const StringPiece& template_id);
+
+// A helper function that generates a string of HTML to be loaded. The
+// string includes the HTML and the javascript code necessary to generate the
+// full page with support for i18n Templates.
+std::string GetI18nTemplateHtml(const StringPiece& html_template,
+ const DictionaryValue* json);
+
+// A helper function that generates a string of HTML to be loaded. The
+// string includes the HTML and the javascript code necessary to generate the
+// full page with support for both i18n Templates and JsTemplates.
+std::string GetTemplatesHtml(const StringPiece& html_template,
+ const DictionaryValue* json,
+ const StringPiece& template_id);
+
+// The following functions build up the different parts that the above
+// templates use.
+
+// Appends a script tag with a variable name |templateData| that has the JSON
+// assigned to it.
+void AppendJsonHtml(const DictionaryValue* json, std::string* output);
+
+// Appends the source for JsTemplates in a script tag.
+void AppendJsTemplateSourceHtml(std::string* output);
+
+// Appends the code that processes the JsTemplate with the JSON. You should
+// call AppendJsTemplateSourceHtml and AppendJsonHtml before calling this.
+void AppendJsTemplateProcessHtml(const StringPiece& template_id,
+ std::string* output);
+
+// Appends the source for i18n Templates in a script tag.
+void AppendI18nTemplateSourceHtml(std::string* output);
+
+// Appends the code that processes the i18n Template with the JSON. You
+// should call AppendJsTemplateSourceHtml and AppendJsonHtml before calling
+// this.
+void AppendI18nTemplateProcessHtml(std::string* output);
+
} // namespace jstemplate_builder
#endif // CHROME_COMMON_JSTEMPLATE_BUILDER_H_