Fork me on GitHub

Template

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

Help

If you experience a problem, you can

  1. submit questions to:HTTL problem management
  2. participate QQ group: 184287288
  3. maillist: httl-user A googlegroups D com
    1. - subscribe: httl-user+subscribe A googlegroups D com
    2. - unsubscribe: httl-user+unsubscribe A googlegroups D com
    3. - online: https://groups.google.com/forum/#!forum/httl-user

member

creator (Founder)

liangfei

submitter (Committer)

liding
  • Li Ding (Aliyun - Alibaba PAAS Technical Specialist) Hangzhou
  • mail: oldratlee (At) gmail (Dot) com
  • blog:http://oldratlee.com
  • microblogging:http://weibo.com/oldratlee
  • contribution: Configure load, abnormal improvements, bug fixes.

contributors (Contributor)

liding Xwinie ZQQ9
  • mail: zqq_90 (At) 163 (Dot) com
  • contribution: Type Bug Fixes:# 64
Subchen
  • contribution: Remove blank line command to achieve:# 89

user

淘宝网

京东商城

大麦网

团博网

北京互联新网

collection, if you are using HTTL, welcome to provide company name ...

answers

Why use # set

declare variable types?

mandatory declaration of variables # set definition, in order to clear the input template, which can strongly typed compiled improve performance.

also convenient template maintenance, weak type operators for long-term maintenance of Internet applications is extremely unfavorable, thousands of engineers tinkering with the template.

Who remembers what a object attributes, turn turn code documentation, someone changed an attribute of a object is not associated with, nor prompt.

even development IDE editor, can not automatically prompt nor error, such as run-time detection, it is affecting the efficiency of development.

Ali developed internally at a Velocity IDE editor encountered much resistance, have increased through the notes to the template type definition.

See:http://www.infoq.com/cn/articles/hk-semi -static-language

How

like JSP custom tag functionality?

HTTL template to prevent complications and maintain the most simple instruction set, so do not allow users to extend the instruction set, and through the extension functions to achieve the same functionality.

custom tag:...

extend it can be replaced with: # if (hasPrivilege ("foo")) ... # end

simply configure: import.methods + = com.your.YourPrivilegeStaticMethodClass

Compilation failed

appear abnormal how do?

HTTL the compilation fails, it will automatically open-Xlint: unchecked parameter recompiled So users get the exception message, already contains detailed information JDK compiler failed.

If you analyze the reasons

no exception, HTTL simultaneously generated Java code will be printed in the log, You can copy the code out into the IDE, see the IDE error.

appear abnormal class or package not found how to do?

Please check httl, and you are using classes, whether in the classpath.

Please check import.packages

package name is correct.

If JdkCompiler problems, you can try to change JavassistCompiler try to confirm whether the classpath for the JdkCompiler loading problems.

properties or methods can not find how to do?

If the following exception:

No such property xxx in class java.lang.Object

No such method xxx() in class java.lang.Object

is usually the type of the variable is not defined in the template, adding the variable type declaration: # set (Xxx xxx)

occur after the template change does not take effect how to do?

HTTL when it starts printing INFO log shows the loading configuration path, such as:

INFO: Load httl config from / home / foo / httl.properties in classpath.

you can look at your configuration is the log of the share on the print position to avoid multiple copies httl.properties configuration, loaded the wrong configuration file.

If you have multiple copies of configuration, HTTL WARN log will be printed to alert the user, such as:

WARN: Multi httl config in classpath, conflict configs: [/ home / foo / httl.properties, / home / foo / conf / httl.properties]. Please keep only one config.

And, HTTL first template is loaded, it will print the template INFO log shows where the absolute path, such as:

INFO: Load httl template from RELOADABLE directory / home / foo / templates by ClasspathLoader.

you can look at your template is printed in the log template directory, avoid modifying templates does not load the directory, where the thermal load on RELOADABLE represents, in the absence of open heat loads to modify the template requires rebooting.

template rendering garbled how to do?

If garbled, check HTTL encoding configuration:

input.encoding = UTF-8

output.encoding = UTF-8

default values ​​are file.encoding, namely the local operating system file encoding.

addition, MVC integration, the default value will output.encoding write response.setEncodingCharset() in,

Of course, you can also configure response.encoding = null turn off the automatic response encoding settings,

If OutputStream output template, please make sure response.encoding and output.encoding consistent, otherwise the output will be garbled.

Please note, input.encoding refers loaded from disk template coding, and request.getEncodingCharset not related, you can use a different encoding.

command name and text phase how to do?

such as: # elseTEXT, separated by brackets available with no parameters, such as: # if (x) AAA # else() BBB # end() CCC

$ {} placeholders can nest?

HTTL does not support nested placeholders, such as: $ {include ("$ {dir} / file")}, placeholder stitching with a plus sign inside your string, such as: $ {include (dir +" / file")}

involved

participation

you cangithub pullyour changes to us.

You can also directly

code, send us an email: liangfei0201 (At) gmail (Dot) com

participate Content

Documentation Additions

If you find a missing document, or the answer had FAQ, use the experience, as well as your understanding of the details, you can send e-mail to us, we will be posted on this site for others to share their knowledge.

Template Test

you can help test more scenarios template, simply provide test documentation templates and expected results can, such as:

existing test template:src / test / resources / comment / templates

existing test results:src / test / resources / comment / results

can run httl.test.TemplateTest test class, it will automatically scan and implementation templates of all templates, and use results under the same name plus. txt suffix to the output file contents assertions.

fixes

You can help fixgithub issueson the issue.

core improvements

If you are interested to spend more time to participate HTTL, and have some development capabilities can be added to the core of the improvements:

  • interpreted and compiled execution before the automatic switch, similar to the JVM JIT.
  • complete generic derivation, and Java generics derive the same.
  • generate bytecode optimization details, such as reducing instanceof, reduce reflection and reduce packing.
  • exception friendly tips, such as run-time operations error, suggesting that the position in the template.
  • in the thermal loading, unloading support compiled before template class.
  • bytecode support disk cache, reducing the restart compilation.
  • reconstruction AST tree, so that can be extended.

extension implementation

You can also implement

HTTL extension point, including:

  • Static, static methods
  • Loader, load the template
  • Resolver, variable decision
  • Formatter, output format
  • Filter, output filters
  • Converter, rendering parameters Conversion
  • Interceptor, the rendering process to intercept
  • Listener, the rendering process monitoring

framework integration

You can also help integrate various MVC framework, as well as other scenes need to use a template.

aids

You can also help achieve Eclipse, IDEA and other template development plug-ins, and Debug debugging, test viewer and so on.