support template lik PHP, better algorithm v1.4.0