Fork me on GitHub

Template

  • Simple & Friendly
  • High-Performance
  • High-Quality

2013-08-16, HTTL 1.0.11 version has been released, welcome and feedback.

Overview

HTTL (Hyper-Text Template Language) Is a high-performance open source JAVA template engine For dynamic HTML page output, Alternative JSP page, Instructions and Velocity similar.

simple and friendly template syntax

HTTL syntax as compliant with HTML and JAVA developer's intuition, instructions, and a veteran of the Velocity similar, but not improved Velocity intuitive place. Retaining only the most basic conditions iterative control instructions, the rendering process is not allowed to modify the original data, to prevent the introduction of too much business logic in the template. HTML comment syntax used by default, to avoid interference with native HTML page.

<!--#set(List<Book> books)-->
<html>
    <body>
        <!--#if(books)-->
        <table>
            <!--#for(Book book : books)-->
            <tr>
                <td>${book.title}</td>
            </tr>
            <!--#end-->
        </table>
        <!--#end-->
    </body>
</html>

improve Velocity does not comply with intuitive place:

  • command without any increase in the variable $ operators, such as: # if (a == b), rather than the Velocity as: # if ($ a == $ b), add $ bit rubbish, but also easy to forget to write.
  • $ {x} When the variable is null, the output blank string, rather than as Velocity: Output source $ {x}, if $! {x}, an exclamation point is easy to forget to write.
  • support in the output when the expression evaluates as: $ {i + 1}, rather than as Velocity: first # set ($ j = $ i + 1) to a temporary variable.
  • a more intuitive way, call the static utility methods, such as: $ {"a". toChar}, rather than the Velocity as: $ {StringTool.toChar ("a")}.

detailed syntax, and Velocity contrast, see: syntax & comparison

excellence in performance optimization

HTTL template compiled into JAVA bytecode run and use strong type inference to reduce the runtime reflection and transformation, Rendering speeds approaching Java hardcoded output, other than the Velocity template engine an order of magnitude faster. Also faster than JSP because JSP is compiled only Scriptlet, Tag and EL is interpreted rather HTTL is fully compiled.

benchmark

test cases and the environment, as well as optimization strategy, see: performance & optimization

quality design and implementation

HTTL using micronucleus + plug-in system, all the links can be extended or replaced to facilitate the integration and secondary development. Allowed into the Senate declared within a template variable types, so that self-description template types, properties, and methods to facilitate IDE achieve prompt completion of the development process friendly. All error messages pinpoint the ranks, and displays relevant content before and after the error location, easy troubleshooting.

coverage

strictly to ensure quality, ease of use, HTTL before release, has been fully tested:

  • all grammar instruction function template unit tests to ensure that all the templates correctly parse and execute commands.
  • performance comparison benchmarks to ensure that hard-coded output performance close to Java, an order of magnitude higher than the other engines.
  • long-running stability tests to ensure there are no FullGC, memory leaks, deadlocks, CPU fills, and jitter.
  • memory usage and CPU time consuming Profiler analysis to ensure that no unexpected memory and CPU bottlenecks.
  • FindBugs code problem detection, ensure that there is a null pointer, resources are not closed, and so obviously wrong.
  • JDepend subcontracting dependence testing to ensure that sub-reliance is reasonable.
  • Web application integration testing to ensure the SpringMVC, Struts, Webx such integration is available.
  • environmental compatibility testing to ensure the Liunx, Windows, OSX, JDK1.5, 1.6,1.7 and other environments available.

detailed design and quality analysis, see: design & quality