http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/a4004324/builds/2.3.26-nightly/pgui.html ---------------------------------------------------------------------- diff --git a/builds/2.3.26-nightly/pgui.html b/builds/2.3.26-nightly/pgui.html deleted file mode 100644 index 4213288..0000000 --- a/builds/2.3.26-nightly/pgui.html +++ /dev/null @@ -1,54 +0,0 @@ -<!doctype html> -<!-- Generated by FreeMarker/Docgen from DocBook --> -<html lang="en" class="page-type-part"> -<head prefix="og: http://ogp.me/ns#"> -<meta charset="utf-8"> -<title>Programmer's Guide - Apache FreeMarker Manual</title> -<meta http-equiv="X-UA-Compatible" content="IE=edge"> -<meta name="viewport" content="width=device-width,initial-scale=1"> -<meta name="format-detection" content="telephone=no"> -<meta property="og:site_name" content="Apache FreeMarker Manual"> -<meta property="og:title" content="Programmer's Guide"> -<meta property="og:locale" content="en_US"> -<meta property="og:url" content="http://freemarker.org/docs/pgui.html"> -<link rel="canonical" href="http://freemarker.org/docs/pgui.html"> -<link rel="icon" href="favicon.png" type="image/png"> -<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono"> -<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1489402528979"> -<script> -(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ -(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), -m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) -})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); -ga('create', 'UA-55420501-1', 'auto'); -ga('send', 'pageview'); -</script> -</head> -<body itemscope itemtype="https://schema.org/Code"> - <meta itemprop="url" content="http://freemarker.org/docs/"> - <meta itemprop="name" content="Apache FreeMarker Manual"> - - <!--[if lte IE 9]> - <div style="background-color: #C00; color: #fff; padding: 12px 24px;">Please use a modern browser to view this website.</div> - <![endif]--><div class="header-top-bg"><div class="site-width header-top"><a class="logo" href="http://freemarker.org" role="banner"> <img itemprop="image" src="logo.png" alt="FreeMarker"> -</a><ul class="tabs"><li><a href="http://freemarker.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="http://freemarker.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/browse/FREEMARKER/" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="http://freemarker.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="searc h-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></div><div class="site-width breadcrumb-row"><ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="step-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="index.html"><span itemprop="name">Apache FreeMarker Manual</span></a></li><li class="step-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui.html"><span itemprop="name">Programmer's Guide</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_ex p.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width"> - <div class="content-wrapper"> - <div id="table-of-contents-wrapper" class="col-left"> - <script>var breadcrumb = ["Apache FreeMarker Manual","Programmer\'s Guide"];</script> - <script src="toc.js?1489402528979"></script> - <script src="docgen-resources/main.min.js?1489402528979"></script> - </div> -<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="dgui_misc_alternativesyntax.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_quickstart.html"><span>Next</span></a></div><div class="title-wrapper"> -<h1 class="content-header header-part" id="pgui" itemprop="headline">Programmer's Guide</h1> -</div></div><div class="page-menu"> -<div class="page-menu-title">Section Contents</div> -<ul><li><a class="page-menu-link" href="pgui_quickstart.html" data-menu-target="pgui_quickstart">Getting Started</a><ul><li><a class="page-menu-link" href="pgui_quickstart_createconfiguration.html" data-menu-target="pgui_quickstart_createconfiguration">Create a configuration instance</a></li><li><a class="page-menu-link" href="pgui_quickstart_createdatamodel.html" data-menu-target="pgui_quickstart_createdatamodel">Create a data-model</a></li><li><a class="page-menu-link" href="pgui_quickstart_gettemplate.html" data-menu-target="pgui_quickstart_gettemplate">Get the template</a></li><li><a class="page-menu-link" href="pgui_quickstart_merge.html" data-menu-target="pgui_quickstart_merge">Merging the template with the data-model</a></li><li><a class="page-menu-link" href="pgui_quickstart_all.html" data-menu-target="pgui_quickstart_all">Putting all together</a></li></ul></li><li><a class="page-menu-link" href="pgui_datamodel.html" data-menu-target="pgui_datamodel">The Data Model</a><ul><l i><a class="page-menu-link" href="pgui_datamodel_basics.html" data-menu-target="pgui_datamodel_basics">Basics</a></li><li><a class="page-menu-link" href="pgui_datamodel_scalar.html" data-menu-target="pgui_datamodel_scalar">Scalars</a></li><li><a class="page-menu-link" href="pgui_datamodel_parent.html" data-menu-target="pgui_datamodel_parent">Containers</a></li><li><a class="page-menu-link" href="pgui_datamodel_method.html" data-menu-target="pgui_datamodel_method">Methods</a></li><li><a class="page-menu-link" href="pgui_datamodel_directive.html" data-menu-target="pgui_datamodel_directive">Directives</a></li><li><a class="page-menu-link" href="pgui_datamodel_node.html" data-menu-target="pgui_datamodel_node">Node variables</a></li><li><a class="page-menu-link" href="pgui_datamodel_objectWrapper.html" data-menu-target="pgui_datamodel_objectWrapper">Object wrappers</a></li></ul></li><li><a class="page-menu-link" href="pgui_config.html" data-menu-target="pgui_config">The Configuration</a> <ul><li><a class="page-menu-link" href="pgui_config_basics.html" data-menu-target="pgui_config_basics">Basics</a></li><li><a class="page-menu-link" href="pgui_config_sharedvariables.html" data-menu-target="pgui_config_sharedvariables">Shared variables</a></li><li><a class="page-menu-link" href="pgui_config_settings.html" data-menu-target="pgui_config_settings">Settings</a></li><li><a class="page-menu-link" href="pgui_config_templateloading.html" data-menu-target="pgui_config_templateloading">Template loading</a></li><li><a class="page-menu-link" href="pgui_config_errorhandling.html" data-menu-target="pgui_config_errorhandling">Error handling</a></li><li><a class="page-menu-link" href="pgui_config_templateconfigurations.html" data-menu-target="pgui_config_templateconfigurations">Template configurations</a></li><li><a class="page-menu-link" href="pgui_config_outputformatsautoesc.html" data-menu-target="pgui_config_outputformatsautoesc">Associating output formats with templates</a></li ><li><a class="page-menu-link" href="pgui_config_custom_formats.html" >data-menu-target="pgui_config_custom_formats">Custom number and date/time >formats</a></li><li><a class="page-menu-link" >href="pgui_config_incompatible_improvements.html" >data-menu-target="pgui_config_incompatible_improvements">The >"incompatible improvements" setting</a></li></ul></li><li><a >class="page-menu-link" href="pgui_misc.html" >data-menu-target="pgui_misc">Miscellaneous</a><ul><li><a >class="page-menu-link" href="pgui_misc_var.html" >data-menu-target="pgui_misc_var">Variables, scopes</a></li><li><a >class="page-menu-link" href="pgui_misc_charset.html" >data-menu-target="pgui_misc_charset">Charset issues</a></li><li><a >class="page-menu-link" href="pgui_misc_multithreading.html" >data-menu-target="pgui_misc_multithreading">Multithreading</a></li><li><a >class="page-menu-link" href="pgui_misc_beanwrapper.html" >data-menu-target="pgui_misc_beanwrapper">Bean wrapper</a></li><li><a >class="page-menu-link" href= "pgui_misc_logging.html" data-menu-target="pgui_misc_logging">Logging</a></li><li><a class="page-menu-link" href="pgui_misc_servlet.html" data-menu-target="pgui_misc_servlet">Using FreeMarker with servlets</a></li><li><a class="page-menu-link" href="pgui_misc_secureenv.html" data-menu-target="pgui_misc_secureenv">Configuring security policy for FreeMarker</a></li><li><a class="page-menu-link" href="pgui_misc_xml_legacy.html" data-menu-target="pgui_misc_xml_legacy">Legacy XML wrapper implementation</a></li><li><a class="page-menu-link" href="pgui_misc_ant.html" data-menu-target="pgui_misc_ant">Using FreeMarker with Ant</a></li><li><a class="page-menu-link" href="pgui_misc_jythonwrapper.html" data-menu-target="pgui_misc_jythonwrapper">Jython wrapper</a></li></ul></li></ul> </div><div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="dgui_misc_alternativesyntax.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_quickstar t.html"><span>Next</span></a></div></div></div></div> </div> - </div> -<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="http://freemarker.org/">What is FreeMarker?</a></li><li><a href="http://freemarker.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="http://freemarker.org/history.html">About us</a></li><li><a itemprop="license" href="app_license.html">License</a></li></ul></div><div class="column"><h3 class="column-header">Handy stuff</h3><ul><li><a href="http://freemarker-online.kenshoo.com/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href ="https://github.com/freemarker/freemarker">FreeMarker on Github</a></li><li><a href="https://twitter.com/freemarker">Follow us on Twitter</a></li><li><a href="https://issues.apache.org/jira/browse/FREEMARKER/">Report a bug</a></li><li><a href="http://stackoverflow.com/questions/ask?tags=freemarker">Ask a question</a></li><li><a href="http://freemarker.org/mailing-lists.html">Mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/freemarker/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="http://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated"> -Last generated: -<time itemprop="dateModified" datetime="2017-03-13T10:55:28Z" title="Monday, March 13, 2017 10:55:28 AM GMT">2017-03-13 10:55:28 GMT</time>, for Freemarker 2.3.26 </p> -<p class="copyright"> -© <span itemprop="copyrightYear">1999</span>â2017 -<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. </p> -</div></div></div></body> -</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/a4004324/builds/2.3.26-nightly/pgui_config.html ---------------------------------------------------------------------- diff --git a/builds/2.3.26-nightly/pgui_config.html b/builds/2.3.26-nightly/pgui_config.html deleted file mode 100644 index f6feea0..0000000 --- a/builds/2.3.26-nightly/pgui_config.html +++ /dev/null @@ -1,55 +0,0 @@ -<!doctype html> -<!-- Generated by FreeMarker/Docgen from DocBook --> -<html lang="en" class="page-type-chapter"> -<head prefix="og: http://ogp.me/ns#"> -<meta charset="utf-8"> -<title>The Configuration - Apache FreeMarker Manual</title> -<meta http-equiv="X-UA-Compatible" content="IE=edge"> -<meta name="viewport" content="width=device-width,initial-scale=1"> -<meta name="format-detection" content="telephone=no"> -<meta property="og:site_name" content="Apache FreeMarker Manual"> -<meta property="og:title" content="The Configuration"> -<meta property="og:locale" content="en_US"> -<meta property="og:url" content="http://freemarker.org/docs/pgui_config.html"> -<link rel="canonical" href="http://freemarker.org/docs/pgui_config.html"> -<link rel="icon" href="favicon.png" type="image/png"> -<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono"> -<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1489402528979"> -<script> -(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ -(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), -m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) -})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); -ga('create', 'UA-55420501-1', 'auto'); -ga('send', 'pageview'); -</script> -</head> -<body itemscope itemtype="https://schema.org/Code"> - <meta itemprop="url" content="http://freemarker.org/docs/"> - <meta itemprop="name" content="Apache FreeMarker Manual"> - - <!--[if lte IE 9]> - <div style="background-color: #C00; color: #fff; padding: 12px 24px;">Please use a modern browser to view this website.</div> - <![endif]--><div class="header-top-bg"><div class="site-width header-top"><a class="logo" href="http://freemarker.org" role="banner"> <img itemprop="image" src="logo.png" alt="FreeMarker"> -</a><ul class="tabs"><li><a href="http://freemarker.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="http://freemarker.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/browse/FREEMARKER/" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="http://freemarker.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="searc h-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></div><div class="site-width breadcrumb-row"><ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="step-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="index.html"><span itemprop="name">Apache FreeMarker Manual</span></a></li><li class="step-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui.html"><span itemprop="name">Programmer's Guide</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_config.html"><span itemprop="name">The Configuration</span></a></li></ul><div class="bookmark s" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width"> - <div class="content-wrapper"> - <div id="table-of-contents-wrapper" class="col-left"> - <script>var breadcrumb = ["Apache FreeMarker Manual","Programmer\'s Guide","The Configuration"];</script> - <script src="toc.js?1489402528979"></script> - <script src="docgen-resources/main.min.js?1489402528979"></script> - </div> -<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="pgui_datamodel_objectWrapper.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_config_basics.html"><span>Next</span></a></div><div class="title-wrapper"> -<h1 class="content-header header-chapter" id="pgui_config" itemprop="headline">The Configuration</h1> -</div></div><div class="page-menu"> -<div class="page-menu-title">Section Contents</div> -<ul><li><a class="page-menu-link" href="pgui_config_basics.html" data-menu-target="pgui_config_basics">Basics</a></li><li><a class="page-menu-link" href="pgui_config_sharedvariables.html" data-menu-target="pgui_config_sharedvariables">Shared variables</a></li><li><a class="page-menu-link" href="pgui_config_settings.html" data-menu-target="pgui_config_settings">Settings</a></li><li><a class="page-menu-link" href="pgui_config_templateloading.html" data-menu-target="pgui_config_templateloading">Template loading</a></li><li><a class="page-menu-link" href="pgui_config_errorhandling.html" data-menu-target="pgui_config_errorhandling">Error handling</a></li><li><a class="page-menu-link" href="pgui_config_templateconfigurations.html" data-menu-target="pgui_config_templateconfigurations">Template configurations</a></li><li><a class="page-menu-link" href="pgui_config_outputformatsautoesc.html" data-menu-target="pgui_config_outputformatsautoesc">Associating output formats with templates</a></li ><li><a class="page-menu-link" href="pgui_config_custom_formats.html" >data-menu-target="pgui_config_custom_formats">Custom number and date/time >formats</a></li><li><a class="page-menu-link" >href="pgui_config_incompatible_improvements.html" >data-menu-target="pgui_config_incompatible_improvements">The >"incompatible improvements" setting</a></li></ul> </div><p>This is >just an overview. See the <a href="api/index.html">FreeMarker Java API >documentation</a> for the - details.</p><div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="pgui_datamodel_objectWrapper.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_config_basics.html"><span>Next</span></a></div></div></div></div> </div> - </div> -<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="http://freemarker.org/">What is FreeMarker?</a></li><li><a href="http://freemarker.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="http://freemarker.org/history.html">About us</a></li><li><a itemprop="license" href="app_license.html">License</a></li></ul></div><div class="column"><h3 class="column-header">Handy stuff</h3><ul><li><a href="http://freemarker-online.kenshoo.com/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href ="https://github.com/freemarker/freemarker">FreeMarker on Github</a></li><li><a href="https://twitter.com/freemarker">Follow us on Twitter</a></li><li><a href="https://issues.apache.org/jira/browse/FREEMARKER/">Report a bug</a></li><li><a href="http://stackoverflow.com/questions/ask?tags=freemarker">Ask a question</a></li><li><a href="http://freemarker.org/mailing-lists.html">Mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/freemarker/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="http://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated"> -Last generated: -<time itemprop="dateModified" datetime="2017-03-13T10:55:28Z" title="Monday, March 13, 2017 10:55:28 AM GMT">2017-03-13 10:55:28 GMT</time>, for Freemarker 2.3.26 </p> -<p class="copyright"> -© <span itemprop="copyrightYear">1999</span>â2017 -<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. </p> -</div></div></div></body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/a4004324/builds/2.3.26-nightly/pgui_config_basics.html ---------------------------------------------------------------------- diff --git a/builds/2.3.26-nightly/pgui_config_basics.html b/builds/2.3.26-nightly/pgui_config_basics.html deleted file mode 100644 index 47c8a9a..0000000 --- a/builds/2.3.26-nightly/pgui_config_basics.html +++ /dev/null @@ -1,75 +0,0 @@ -<!doctype html> -<!-- Generated by FreeMarker/Docgen from DocBook --> -<html lang="en" class="page-type-section"> -<head prefix="og: http://ogp.me/ns#"> -<meta charset="utf-8"> -<title>Basics - Apache FreeMarker Manual</title> -<meta http-equiv="X-UA-Compatible" content="IE=edge"> -<meta name="viewport" content="width=device-width,initial-scale=1"> -<meta name="format-detection" content="telephone=no"> -<meta property="og:site_name" content="Apache FreeMarker Manual"> -<meta property="og:title" content="Basics"> -<meta property="og:locale" content="en_US"> -<meta property="og:url" content="http://freemarker.org/docs/pgui_config_basics.html"> -<link rel="canonical" href="http://freemarker.org/docs/pgui_config_basics.html"> -<link rel="icon" href="favicon.png" type="image/png"> -<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono"> -<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1489402528979"> -<script> -(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ -(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), -m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) -})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); -ga('create', 'UA-55420501-1', 'auto'); -ga('send', 'pageview'); -</script> -</head> -<body itemscope itemtype="https://schema.org/Code"> - <meta itemprop="url" content="http://freemarker.org/docs/"> - <meta itemprop="name" content="Apache FreeMarker Manual"> - - <!--[if lte IE 9]> - <div style="background-color: #C00; color: #fff; padding: 12px 24px;">Please use a modern browser to view this website.</div> - <![endif]--><div class="header-top-bg"><div class="site-width header-top"><a class="logo" href="http://freemarker.org" role="banner"> <img itemprop="image" src="logo.png" alt="FreeMarker"> -</a><ul class="tabs"><li><a href="http://freemarker.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="http://freemarker.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/browse/FREEMARKER/" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="http://freemarker.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="searc h-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></div><div class="site-width breadcrumb-row"><ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="step-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="index.html"><span itemprop="name">Apache FreeMarker Manual</span></a></li><li class="step-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui.html"><span itemprop="name">Programmer's Guide</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_config.html"><span itemprop="name">The Configuration</span></a></li><li class="step-3" itempr op="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_config_basics.html"><span itemprop="name">Basics</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width"> - <div class="content-wrapper"> - <div id="table-of-contents-wrapper" class="col-left"> - <script>var breadcrumb = ["Apache FreeMarker Manual","Programmer\'s Guide","The Configuration","Basics"];</script> - <script src="toc.js?1489402528979"></script> - <script src="docgen-resources/main.min.js?1489402528979"></script> - </div> -<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="pgui_config.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_config_sharedvariables.html"><span>Next</span></a></div><div class="title-wrapper"> -<h1 class="content-header header-section1" id="pgui_config_basics" itemprop="headline">Basics</h1> -</div></div><p>First of all, be sure you have read the <a href="pgui_quickstart_createconfiguration.html">Getting Started</a> - chapter.</p><p>A configuration is a - <code class="inline-code">freemarker.template.Configuration</code> object that - stores your common (global, application level) settings and defines - variables that you want to be available in all templates (so called - shared variables). Also, it deals with the creation and caching of - <code class="inline-code">Template</code> instances.</p><p>An application typically uses only a single shared - <code class="inline-code">Configuration</code> instance. More precisely, typically - you have one <code class="inline-code">Configuration</code> instance per - independently developed component that internally uses FreeMarker, so - they can be configured independently of each other. For example, your - e-mail sender component and your report generator component (service) - probably want to use their own <code class="inline-code">Configuration</code>-s, as - their needs differ.</p><p>As the behavior of templates depends on the configuration - settings, each <code class="inline-code">Template</code> instance has an associated - <code class="inline-code">Configuration</code> instance. If you obtain the - <code class="inline-code">Template</code> instances with - <code class="inline-code">Configuration.getTemplate</code>, the associated - <code class="inline-code">Configuration</code> instance will be the one whose - <code class="inline-code">getTemplate</code> method was called. If you create the - <code class="inline-code">Template</code> instances directly with the - <code class="inline-code">Template</code> constructor, the - <code class="inline-code">Configuration</code> should be specified as constructor - parameter.</p><div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="pgui_config.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_config_sharedvariables.html"><span>Next</span></a></div></div></div></div> </div> - </div> -<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="http://freemarker.org/">What is FreeMarker?</a></li><li><a href="http://freemarker.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="http://freemarker.org/history.html">About us</a></li><li><a itemprop="license" href="app_license.html">License</a></li></ul></div><div class="column"><h3 class="column-header">Handy stuff</h3><ul><li><a href="http://freemarker-online.kenshoo.com/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href ="https://github.com/freemarker/freemarker">FreeMarker on Github</a></li><li><a href="https://twitter.com/freemarker">Follow us on Twitter</a></li><li><a href="https://issues.apache.org/jira/browse/FREEMARKER/">Report a bug</a></li><li><a href="http://stackoverflow.com/questions/ask?tags=freemarker">Ask a question</a></li><li><a href="http://freemarker.org/mailing-lists.html">Mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/freemarker/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="http://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated"> -Last generated: -<time itemprop="dateModified" datetime="2017-03-13T10:55:28Z" title="Monday, March 13, 2017 10:55:28 AM GMT">2017-03-13 10:55:28 GMT</time>, for Freemarker 2.3.26 </p> -<p class="copyright"> -© <span itemprop="copyrightYear">1999</span>â2017 -<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. </p> -</div></div></div></body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/a4004324/builds/2.3.26-nightly/pgui_config_custom_formats.html ---------------------------------------------------------------------- diff --git a/builds/2.3.26-nightly/pgui_config_custom_formats.html b/builds/2.3.26-nightly/pgui_config_custom_formats.html deleted file mode 100644 index 1c083eb..0000000 --- a/builds/2.3.26-nightly/pgui_config_custom_formats.html +++ /dev/null @@ -1,700 +0,0 @@ -<!doctype html> -<!-- Generated by FreeMarker/Docgen from DocBook --> -<html lang="en" class="page-type-section"> -<head prefix="og: http://ogp.me/ns#"> -<meta charset="utf-8"> -<title>Custom number and date/time formats - Apache FreeMarker Manual</title> -<meta http-equiv="X-UA-Compatible" content="IE=edge"> -<meta name="viewport" content="width=device-width,initial-scale=1"> -<meta name="format-detection" content="telephone=no"> -<meta property="og:site_name" content="Apache FreeMarker Manual"> -<meta property="og:title" content="Custom number and date/time formats"> -<meta property="og:locale" content="en_US"> -<meta property="og:url" content="http://freemarker.org/docs/pgui_config_custom_formats.html"> -<link rel="canonical" href="http://freemarker.org/docs/pgui_config_custom_formats.html"> -<link rel="icon" href="favicon.png" type="image/png"> -<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono"> -<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1489402528979"> -<script> -(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ -(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), -m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) -})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); -ga('create', 'UA-55420501-1', 'auto'); -ga('send', 'pageview'); -</script> -</head> -<body itemscope itemtype="https://schema.org/Code"> - <meta itemprop="url" content="http://freemarker.org/docs/"> - <meta itemprop="name" content="Apache FreeMarker Manual"> - - <!--[if lte IE 9]> - <div style="background-color: #C00; color: #fff; padding: 12px 24px;">Please use a modern browser to view this website.</div> - <![endif]--><div class="header-top-bg"><div class="site-width header-top"><a class="logo" href="http://freemarker.org" role="banner"> <img itemprop="image" src="logo.png" alt="FreeMarker"> -</a><ul class="tabs"><li><a href="http://freemarker.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="http://freemarker.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/browse/FREEMARKER/" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="http://freemarker.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="searc h-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></div><div class="site-width breadcrumb-row"><ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="step-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="index.html"><span itemprop="name">Apache FreeMarker Manual</span></a></li><li class="step-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui.html"><span itemprop="name">Programmer's Guide</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_config.html"><span itemprop="name">The Configuration</span></a></li><li class="step-3" itempr op="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_config_custom_formats.html"><span itemprop="name">Custom number and date/time formats</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width"> - <div class="content-wrapper"> - <div id="table-of-contents-wrapper" class="col-left"> - <script>var breadcrumb = ["Apache FreeMarker Manual","Programmer\'s Guide","The Configuration","Custom number and date/time formats"];</script> - <script src="toc.js?1489402528979"></script> - <script src="docgen-resources/main.min.js?1489402528979"></script> - </div> -<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="pgui_config_outputformatsautoesc.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_config_incompatible_improvements.html"><span>Next</span></a></div><div class="title-wrapper"> -<h1 class="content-header header-section1" id="pgui_config_custom_formats" itemprop="headline">Custom number and date/time formats</h1> -</div></div><div class="page-menu"> -<div class="page-menu-title">Page Contents</div> -<ul><li><a class="page-menu-link" href="#autoid_50" data-menu-target="autoid_50">Overview</a></li><li><a class="page-menu-link" href="#pgui_config_custom_formats_ex_cust_alg_simple" data-menu-target="pgui_config_custom_formats_ex_cust_alg_simple">Simple custom number format example</a></li><li><a class="page-menu-link" href="#pgui_config_custom_formats_ex_cust_algo_advanced" data-menu-target="pgui_config_custom_formats_ex_cust_algo_advanced">Advanced custom number format example</a></li><li><a class="page-menu-link" href="#pgui_config_custom_formats_ex_cust_algo_date" data-menu-target="pgui_config_custom_formats_ex_cust_algo_date">Custom date/time format example</a></li><li><a class="page-menu-link" href="#pgui_config_custom_formats_ex_alias" data-menu-target="pgui_config_custom_formats_ex_alias">Alias format example</a></li><li><a class="page-menu-link" href="#pgui_config_custom_formats_ex_model_aware" data-menu-target="pgui_config_custom_formats_ex_model_aware">Model-aware format example</a></li></ul> </div> - - - - -<h2 class="content-header header-section2" id="autoid_50">Overview</h2> - - - <p>FreeMarker allows you to define your own number and - date/time/datetime formats, and associate a name to them. This - mechanism has several applications:</p> - - <ul> - <li> - <p>Custom formatter algorithms: You can use your own - formatter algorithm instead of relying on those provided by - FreeMarker. For this, implement - <code class="inline-code">freemarker.core.TemplateNumberFormatFactory</code> - or <code class="inline-code">freemarker.core.TemplateDateFormatFactory</code>. - You will find a few examples of this <a href="#pgui_config_custom_formats_ex_cust_alg_simple">below</a>.</p> - </li> - - <li> - <p>Aliasing: You can give application-specific names (like - "price", "weight", - "fileDate", "logEventTime", etc.) to - other formats by using - <code class="inline-code">AliasTemplateNumberFormatFactory</code> and - <code class="inline-code">AliasTemplateDateFormatFactory</code>. Thus - templates can just refer to that name, like in - <code class="inline-code">${lastModified?string.@fileDate}</code>, instead of - specifying the format directly. Thus the formats can be - specified on a single central place (where you configure - FreeMarker), instead of being specified repeatedly in templates. - Also thus template authors don't have to enter complex and hard - to remember formatting patterns. <a href="#pgui_config_custom_formats_ex_alias">See example - below</a>.</p> - </li> - - <li> - <p>Model-sensitive formatting: Applications can put custom - <code class="inline-code">freemarker.TemplateModel</code>-s into the - data-model instead of dropping plain values (like - <code class="inline-code">int</code>-s, <code class="inline-code">double</code>-s, etc.) - into it, to attach rendering-related information to the value. - Custom formatters can utilize this information (for example, to - show the unit after numbers), as they receive the - <code class="inline-code">TemplateModel</code> itself, not the wrapped raw - value. <a href="#pgui_config_custom_formats_ex_model_aware">See example - below</a>.</p> - </li> - - <li> - <p>Format that prints markup instead of plain text: You might - want to use HTML tags (or other markup) in the formatted values, - such as coloring negative numbers to red or using HTML - <code class="inline-code">sup</code> element for exponents. This is possible - if you write a custom format as shown in previous cases, but - override the <code class="inline-code">format</code> method in the formatter - class so that it returns a - <code class="inline-code">TemplateMarkupOutputModel</code> instead of a - <code class="inline-code">String</code>. (You shouldn't just return the markup - as <code class="inline-code">String</code>, as then it might will be escaped; - see <a href="dgui_misc_autoescaping.html">auto-escaping</a>.)</p> - </li> - </ul> - - <p>Custom formats can be registered with the - <code class="inline-code">custom_number_formats</code> and - <code class="inline-code">custom_date_formats</code> configuration settings. After - that, anywhere where you can specify formats with a - <code class="inline-code">String</code>, now you can refer to your custom format - as <code class="inline-code">"@<em class="code-color">name</em>"</code>. So for - example, if you have registered your number format implementation - with name <code class="inline-code">"smart"</code>, then you could set the - <code class="inline-code">number_format</code> setting - (<code class="inline-code">Configurable.setNumberFormat(String)</code>) to - <code class="inline-code">"@smart"</code>, or issue - <code class="inline-code">${n?string.@smart}</code> or <code class="inline-code"><#setting - number_format="@smart"></code> in a template. Furthermore, you - can define parameters for your custom format, like <code class="inline-code">"@smart - 2"</code>, and the interpretation of the parameters is up to your - formatter implementation.</p> - - - - - -<h2 class="content-header header-section2" id="pgui_config_custom_formats_ex_cust_alg_simple">Simple custom number format example</h2> - - - <p>This custom number format shows numbers in hexadecimal - form:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">package com.example; - -import java.util.Locale; - -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateNumberModel; -import freemarker.template.utility.NumberUtil; - -public class HexTemplateNumberFormatFactory extends TemplateNumberFormatFactory { - - public static final HexTemplateNumberFormatFactory INSTANCE - = new HexTemplateNumberFormatFactory(); - - private HexTemplateNumberFormatFactory() { - // Defined to decrease visibility - } - - @Override - public TemplateNumberFormat get(String params, Locale locale, Environment env) - throws InvalidFormatParametersException { - TemplateFormatUtil.checkHasNoParameters(params); - return HexTemplateNumberFormat.INSTANCE; - } - - private static class HexTemplateNumberFormat extends TemplateNumberFormat { - - private static final HexTemplateNumberFormat INSTANCE = new HexTemplateNumberFormat(); - - private HexTemplateNumberFormat() { } - - @Override - public String formatToPlainText(TemplateNumberModel numberModel) - throws UnformattableValueException, TemplateModelException { - Number n = TemplateFormatUtil.getNonNullNumber(numberModel); - try { - return Integer.toHexString(NumberUtil.toIntExact(n)); - } catch (ArithmeticException e) { - throw new UnformattableValueException(n + " doesn't fit into an int"); - } - } - - @Override - public boolean isLocaleBound() { - return false; - } - - @Override - public String getDescription() { - return "hexadecimal int"; - } - - } - -}</pre></div> - - <p>We register the above format with name - "hex":</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">// Where you initalize the application-wide Configuration singleton: -Configuration cfg = ...; -... -Map<String, TemplateNumberFormatFactory> customNumberFormats = ...; -... -customNumberFormats.put("hex", HexTemplateNumberFormatFactory.INSTANCE); -... -cfg.setCustomNumberFormats(customNumberFormats);</pre></div> - - <p>Now we can use this format in templates:</p> - - - -<div class="code-wrapper"><pre class="code-block code-template">${x?string.@hex}</pre></div> - - <p>or even set it as the default number format:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">cfg.setNumberFormat("@hex");</pre></div> - - - - - -<h2 class="content-header header-section2" id="pgui_config_custom_formats_ex_cust_algo_advanced">Advanced custom number format example</h2> - - - <p>This is a more complex custom number format that shows how to - deal with parameters in the format string, also how to delegate to - another format:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">package com.example; - -import java.util.Locale; - -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateNumberModel; -import freemarker.template.utility.NumberUtil; -import freemarker.template.utility.StringUtil; - -/** - * Shows a number in base N number system. Can only format numbers that fit into an {@code int}, - * however, optionally you can specify a fallback format. This format has one required parameter, - * the numerical system base. That can be optionally followed by "|" and a fallback format. - */ -public class BaseNTemplateNumberFormatFactory extends TemplateNumberFormatFactory { - - public static final BaseNTemplateNumberFormatFactory INSTANCE - = new BaseNTemplateNumberFormatFactory(); - - private BaseNTemplateNumberFormatFactory() { - // Defined to decrease visibility - } - - @Override - public TemplateNumberFormat get(String params, Locale locale, Environment env) - throws InvalidFormatParametersException { - TemplateNumberFormat fallbackFormat; - { - int barIdx = params.indexOf('|'); - if (barIdx != -1) { - String fallbackFormatStr = params.substring(barIdx + 1); - params = params.substring(0, barIdx); - try { - fallbackFormat = env.getTemplateNumberFormat(fallbackFormatStr, locale); - } catch (TemplateValueFormatException e) { - throw new InvalidFormatParametersException( - "Couldn't get the fallback number format (specified after the \"|\"), " - + StringUtil.jQuote(fallbackFormatStr) + ". Reason: " + e.getMessage(), - e); - } - } else { - fallbackFormat = null; - } - } - - int base; - try { - base = Integer.parseInt(params); - } catch (NumberFormatException e) { - if (params.length() == 0) { - throw new InvalidFormatParametersException( - "A format parameter is required to specify the numerical system base."); - } - throw new InvalidFormatParametersException( - "The format paramter must be an integer, but was (shown quoted): " - + StringUtil.jQuote(params)); - } - if (base < 2) { - throw new InvalidFormatParametersException("A base must be at least 2."); - } - return new BaseNTemplateNumberFormat(base, fallbackFormat); - } - - private static class BaseNTemplateNumberFormat extends TemplateNumberFormat { - - private final int base; - private final TemplateNumberFormat fallbackFormat; - - private BaseNTemplateNumberFormat(int base, TemplateNumberFormat fallbackFormat) { - this.base = base; - this.fallbackFormat = fallbackFormat; - } - - @Override - public String formatToPlainText(TemplateNumberModel numberModel) - throws TemplateModelException, TemplateValueFormatException { - Number n = TemplateFormatUtil.getNonNullNumber(numberModel); - try { - return Integer.toString(NumberUtil.toIntExact(n), base); - } catch (ArithmeticException e) { - if (fallbackFormat == null) { - throw new UnformattableValueException( - n + " doesn't fit into an int, and there was no fallback format " - + "specified."); - } else { - return fallbackFormat.formatToPlainText(numberModel); - } - } - } - - @Override - public boolean isLocaleBound() { - return false; - } - - @Override - public String getDescription() { - return "base " + base; - } - - } - -}</pre></div> - - <p>We register the above format with name - "base":</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">// Where you initalize the application-wide Configuration singleton: -Configuration cfg = ...; -... -Map<String, TemplateNumberFormatFactory> customNumberFormats = ...; -... -customNumberFormats.put("base", BaseNTemplateNumberFormatFactory.INSTANCE); -... -cfg.setCustomNumberFormats(customNumberFormats);</pre></div> - - <p>Now we can use this format in templates:</p> - - - -<div class="code-wrapper"><pre class="code-block code-template">${x?string.@base_8}</pre></div> - - <p>Above there the parameter string was <code class="inline-code">"8"</code>, - as FreeMarker allows separating that from the format name with - <code class="inline-code">_</code> instead of whitespace, so that you don't have - to write the longer - <code class="inline-code"><em class="code-color">n</em>?string["@base 8"]</code> - form.</p> - - <p>Of course, we could also set this as the default number format - like:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">cfg.setNumberFormat("@base 8");</pre></div> - - <p>Here's an example of using the a fallback number format (which - is <code class="inline-code">"0.0###"</code>):</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">cfg.setNumberFormat("@base 8|0.0###");</pre></div> - - <p>Note that this functionality, with the <code class="inline-code">|</code> - syntax and all, is purely implemented in the example code - earlier.</p> - - - - - -<h2 class="content-header header-section2" id="pgui_config_custom_formats_ex_cust_algo_date">Custom date/time format example</h2> - - - <p>This simple date format formats the date/time value to the - milliseconds since the epoch:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">package com.example; - -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; - -import freemarker.template.TemplateDateModel; -import freemarker.template.TemplateModelException; - -public class EpochMillisTemplateDateFormatFactory extends TemplateDateFormatFactory { - - public static final EpochMillisTemplateDateFormatFactory INSTANCE - = new EpochMillisTemplateDateFormatFactory(); - - private EpochMillisTemplateDateFormatFactory() { - // Defined to decrease visibility - } - - @Override - public TemplateDateFormat get(String params, int dateType, - Locale locale, TimeZone timeZone, boolean zonelessInput, - Environment env) - throws InvalidFormatParametersException { - TemplateFormatUtil.checkHasNoParameters(params); - return EpochMillisTemplateDateFormat.INSTANCE; - } - - private static class EpochMillisTemplateDateFormat extends TemplateDateFormat { - - private static final EpochMillisTemplateDateFormat INSTANCE - = new EpochMillisTemplateDateFormat(); - - private EpochMillisTemplateDateFormat() { } - - @Override - public String formatToPlainText(TemplateDateModel dateModel) - throws UnformattableValueException, TemplateModelException { - return String.valueOf(TemplateFormatUtil.getNonNullDate(dateModel).getTime()); - } - - @Override - public boolean isLocaleBound() { - return false; - } - - @Override - public boolean isTimeZoneBound() { - return false; - } - - @Override - public Date parse(String s, int dateType) throws UnparsableValueException { - try { - return new Date(Long.parseLong(s)); - } catch (NumberFormatException e) { - throw new UnparsableValueException("Malformed long"); - } - } - - @Override - public String getDescription() { - return "millis since the epoch"; - } - - } - -}</pre></div> - - <p>We register the above format with name - "epoch":</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">// Where you initalize the application-wide Configuration singleton: -Configuration cfg = ...; -... -Map<String, TemplateDateFormatFactory> customDateFormats = ...; -... -customDateFormats.put("epoch", EpochMillisTemplateDateFormatFactory.INSTANCE); -... -cfg.setCustomDateFormats(customDateFormats);</pre></div> - - <p>Now we can use this format in templates:</p> - - - -<div class="code-wrapper"><pre class="code-block code-template">${t?string.@epoch}</pre></div> - - <p>Of course, we could also set this as the default date-time - format like:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">cfg.setDateTimeFormat("@epoch");</pre></div> - - <p>For a more complex that for example uses format parameters, - refer to the <a href="#pgui_config_custom_formats_ex_cust_algo_advanced">advanced - number format example</a>. Doing that with date formats is very - similar.</p> - - - - - -<h2 class="content-header header-section2" id="pgui_config_custom_formats_ex_alias">Alias format example</h2> - - - <p>In this example we specify some number formats and date - formats that are aliases to another format:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">// Where you initalize the application-wide Configuration singleton: -Configuration cfg = ...; - -Map<String, TemplateNumberFormatFactory> customNumberFormats - = new HashMap<String, TemplateNumberFormatFactory>(); -customNumberFormats.put("price", new AliasTemplateNumberFormatFactory(",000.00")); -customNumberFormats.put("weight", - new AliasTemplateNumberFormatFactory("0.##;; roundingMode=halfUp")); -cfg.setCustomNumberFormats(customNumberFormats); - -Map<String, TemplateDateFormatFactory> customDateFormats - = new HashMap<String, TemplateDateFormatFactory>(); -customDateFormats.put("fileDate", new AliasTemplateDateFormatFactory("dd/MMM/yy hh:mm a")); -customDateFormats.put("logEventTime", new AliasTemplateDateFormatFactory("iso ms u")); -cfg.setCustomDateFormats(customDateFormats);</pre></div> - - <p>So now you can do this in a template:</p> - - - -<div class="code-wrapper"><pre class="code-block code-template">${product.price?string.@price} -${product.weight?string.@weight} -${lastModified?string.@fileDate} -${lastError.timestamp?string.@logEventTime}</pre></div> - - <p>Note that the constructor parameter of - <code class="inline-code">AliasTemplateNumberFormatFactory</code> can naturally - refer to a custom format too:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">Map<String, TemplateNumberFormatFactory> customNumberFormats - = new HashMap<String, TemplateNumberFormatFactory>(); -customNumberFormats.put("base", BaseNTemplateNumberFormatFactory.INSTANCE); -customNumberFormats.put("oct", new AliasTemplateNumberFormatFactory("@base 8")); -cfg.setCustomNumberFormats(customNumberFormats);</pre></div> - - <p>So now - <code class="inline-code"><em class="code-color">n</em>?string.@oct</code> will - format the number to octal form.</p> - - - - - -<h2 class="content-header header-section2" id="pgui_config_custom_formats_ex_model_aware">Model-aware format example</h2> - - - <p>In this example we specify a number format that automatically - show the unit after the number if that was put into the data-model - as <code class="inline-code">UnitAwareTemplateNumberModel</code>. First let's see - <code class="inline-code">UnitAwareTemplateNumberModel</code>:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">package com.example; - -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateNumberModel; - -public class UnitAwareTemplateNumberModel implements TemplateNumberModel { - - private final Number value; - private final String unit; - - public UnitAwareTemplateNumberModel(Number value, String unit) { - this.value = value; - this.unit = unit; - } - - @Override - public Number getAsNumber() throws TemplateModelException { - return value; - } - - public String getUnit() { - return unit; - } - -}</pre></div> - - <p>When you fill the data-model, you could do something like - this:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">Map<String, Object> dataModel = new HashMap<>(); -dataModel.put("weight", new UnitAwareTemplateNumberModel(1.5, "kg")); -// Rather than just: dataModel.put("weight", 1.5);</pre></div> - - <p>Then if we have this in the template:</p> - - - -<div class="code-wrapper"><pre class="code-block code-template">${weight}</pre></div> - - <p>we want to see this:</p> - - - -<div class="code-wrapper"><pre class="code-block code-output">1.5 kg</pre></div> - - <p>To achieve that, we define this custom number format:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">package com.example; - -import java.util.Locale; - -import freemarker.core.Environment; -import freemarker.core.TemplateNumberFormat; -import freemarker.core.TemplateNumberFormatFactory; -import freemarker.core.TemplateValueFormatException; -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateNumberModel; - -/** - * A number format that takes any other number format as parameter (specified as a string, as - * usual in FreeMarker), then if the model is a {@link UnitAwareTemplateNumberModel}, it shows - * the unit after the number formatted with the other format, otherwise it just shows the formatted - * number without unit. - */ -public class UnitAwareTemplateNumberFormatFactory extends TemplateNumberFormatFactory { - - public static final UnitAwareTemplateNumberFormatFactory INSTANCE - = new UnitAwareTemplateNumberFormatFactory(); - - private UnitAwareTemplateNumberFormatFactory() { - // Defined to decrease visibility - } - - @Override - public TemplateNumberFormat get(String params, Locale locale, Environment env) - throws TemplateValueFormatException { - return new UnitAwareNumberFormat(env.getTemplateNumberFormat(params, locale)); - } - - private static class UnitAwareNumberFormat extends TemplateNumberFormat { - - private final TemplateNumberFormat innerFormat; - - private UnitAwareNumberFormat(TemplateNumberFormat innerFormat) { - this.innerFormat = innerFormat; - } - - @Override - public String formatToPlainText(TemplateNumberModel numberModel) - throws TemplateModelException, TemplateValueFormatException { - String innerResult = innerFormat.formatToPlainText(numberModel); - return numberModel instanceof UnitAwareTemplateNumberModel - ? innerResult + " " + ((UnitAwareTemplateNumberModel) numberModel).getUnit() - : innerResult; - } - - @Override - public boolean isLocaleBound() { - return innerFormat.isLocaleBound(); - } - - @Override - public String getDescription() { - return "unit-aware " + innerFormat.getDescription(); - } - - } - -}</pre></div> - - <p>Finally, we set the above custom format as the default number - format:</p> - - - -<div class="code-wrapper"><pre class="code-block code-unspecified">// Where you initalize the application-wide Configuration singleton: -Configuration cfg = ...; - -Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<>(); -customNumberFormats.put("ua", UnitAwareTemplateNumberFormatFactory.INSTANCE); -cfg.setCustomNumberFormats(customNumberFormats); - -// Note: "0.####;; roundingMode=halfUp" is a standard format specified in FreeMarker. -cfg.setNumberFormat("@ua 0.####;; roundingMode=halfUp");</pre></div> - <div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="pgui_config_outputformatsautoesc.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_config_incompatible_improvements.html"><span>Next</span></a></div></div></div></div> </div> - </div> -<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="http://freemarker.org/">What is FreeMarker?</a></li><li><a href="http://freemarker.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="http://freemarker.org/history.html">About us</a></li><li><a itemprop="license" href="app_license.html">License</a></li></ul></div><div class="column"><h3 class="column-header">Handy stuff</h3><ul><li><a href="http://freemarker-online.kenshoo.com/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href ="https://github.com/freemarker/freemarker">FreeMarker on Github</a></li><li><a href="https://twitter.com/freemarker">Follow us on Twitter</a></li><li><a href="https://issues.apache.org/jira/browse/FREEMARKER/">Report a bug</a></li><li><a href="http://stackoverflow.com/questions/ask?tags=freemarker">Ask a question</a></li><li><a href="http://freemarker.org/mailing-lists.html">Mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/freemarker/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="http://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated"> -Last generated: -<time itemprop="dateModified" datetime="2017-03-13T10:55:28Z" title="Monday, March 13, 2017 10:55:28 AM GMT">2017-03-13 10:55:28 GMT</time>, for Freemarker 2.3.26 </p> -<p class="copyright"> -© <span itemprop="copyrightYear">1999</span>â2017 -<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. </p> -</div></div></div></body> -</html>
