<commit_before>JST - Java Simple Template
==========================

JST is a simple template engine which use Java as its programming language and produces Java files to be called anywhere from your code.

Why Yet Another Template Engine ?
---------------------------------

Lot's of template engines try to enforce the MVC pattern (Model View Controller) by limitting the algorithmic features of the language used in the templates. Whereas MVC is definitively a good pattern to avoid writing messy software, the philosophy of JST is to let to the developper the responsability to making the separation of the model and the view, not the template engine.

Unlike some template engine, JST is only targeted to the Java environment. The goal is to have a better integration between a business model and the view. Since both are of the same enviroment, they can shares types, and refactoring can be done more easily.

JST can be compared to JSP. But JST doesn't need you to run in a J2EE framework, JST is just about plain Java.

It can be also be compared to the template engine from Playframework 2, since a JST template produces a class callable from your code. But JST don't need a framework, and don't need scala.

The syntax of JST is quite closed to the Velocity one, because it is a nicely concise syntax. But unlike Velocity, JST is typed and properly scoped, no weird side effect is sight.

Last but not least, JST is based on Xtext. Which means an Eclipse editor is already available for use, with syntax coloring, semantic highlighting, compilation error reporting, refactoring.

TODO
----

- escaping: there is currently no escaping when outputing data in an html template.
- while, do-while: these loops are not yet implemented
- for(inst; condition; increm): currently for loops can only iterate on +Iterable+s (+for(item : list)+)

Template Language
-----------------

NB: the programming lnaguage is based on Xbase which a language close to Java, see http://www.eclipse.org/Xtext/documentation.html#xbaseLanguageRef_Introduction

The minimum: define a rendering method in your template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--------------------------------------
#template renderHello()
  Hello World
#end
--------------------------------------

- +#template+ defines a new rendering funtion.
- +myrenderfunction+ is the name of the method to be called from your Java code.
- +()+ is then the list or arguments of your rendering method, here empty.
- +#end+ defines when the rendering of the current method ends.

Outputing expressions
~~~~~~~~~~~~~~~~~~~~~

In the outputed content, juste use +$(aJavaExpression)+. And to output an empty string rather than 'null' on null values, use +$!(aMaybeNullExpression)+<commit_msg>add todo<commit_after>JST - Java Simple Template
==========================

JST is a simple template engine which use Java as its programming language and produces Java files to be called anywhere from your code.

Why Yet Another Template Engine ?
---------------------------------

Lot's of template engines try to enforce the MVC pattern (Model View Controller) by limitting the algorithmic features of the language used in the templates. Whereas MVC is definitively a good pattern to avoid writing messy software, the philosophy of JST is to let to the developper the responsability to making the separation of the model and the view, not the template engine.

Unlike some template engine, JST is only targeted to the Java environment. The goal is to have a better integration between a business model and the view. Since both are of the same enviroment, they can shares types, and refactoring can be done more easily.

JST can be compared to JSP. But JST doesn't need you to run in a J2EE framework, JST is just about plain Java.

It can be also be compared to the template engine from Playframework 2, since a JST template produces a class callable from your code. But JST don't need a framework, and don't need scala.

The syntax of JST is quite closed to the Velocity one, because it is a nicely concise syntax. But unlike Velocity, JST is typed and properly scoped, no weird side effect is sight.

Last but not least, JST is based on Xtext. Which means an Eclipse editor is already available for use, with syntax coloring, semantic highlighting, compilation error reporting, refactoring.

TODO
----

- escaping: there is currently no escaping when outputing data in an html template.
- while, do-while: these loops are not yet implemented
- for(inst; condition; increm): currently for loops can only iterate on +Iterable+s (+for(item : list)+)
- add a #abstracttemplate: same as #template, but generate an abstract method
- add a #call render(args...): should be a synonym of #( render(out, args...); )
- add a servlet option: PrintStream out would come from the HttpServletResponse and HttpServletRequest would be available in the template

Template Language
-----------------

NB: the programming lnaguage is based on Xbase which a language close to Java, see http://www.eclipse.org/Xtext/documentation.html#xbaseLanguageRef_Introduction

The minimum: define a rendering method in your template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--------------------------------------
#template renderHello()
  Hello World
#end
--------------------------------------

- +#template+ defines a new rendering funtion.
- +myrenderfunction+ is the name of the method to be called from your Java code.
- +()+ is then the list or arguments of your rendering method, here empty.
- +#end+ defines when the rendering of the current method ends.

Outputing expressions
~~~~~~~~~~~~~~~~~~~~~

In the outputed content, juste use +$(aJavaExpression)+. And to output an empty string rather than 'null' on null values, use +$!(aMaybeNullExpression)+
{'fraction_non_alphanumeric': 0.12413911845730027, 'fraction_numerical': 0.0006887052341597796, 'mean_word_length': 3.6658634538152612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1015669', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1350, 'n_words': 823}