重构了模版部分的逻辑

Signed-off-by: Meathill <meathill@gmail.com>
改了好多地方，感觉进步很大的样子

Signed-off-by: Meathill <meathill@gmail.com>