# DynamicRender **Repository Path**: doublecc/DynamicRender ## Basic Information - **Project Name**: DynamicRender - **Description**: 通过配置文件[可运行时更改生效]的方式,使用模板引擎(Velocity),运行时渲染SQL(NOT_ONLY_SQL),无框架依赖,可配合jdbc,jdbcTemplate等使用 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-09-09 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #动态渲染(DynamicRender) [![Build Status](https://travis-ci.org/xushunke/DynRenderer.svg?branch=master)](https://travis-ci.org/xushunke/DynRenderer) on GitHub: https://github.com/xushunke/DynRenderer on OSC-Git: http://git.oschina.net/xushunke/DynamicRender > 可使用多种模板引擎(Velocity,Freemarker),基于\[统一]配置\[可运行时更改生效]方式,运行时渲染SQL(NOT\_ONLY\_SQL),无框架依赖,可配合jdbc,jdbcTemplate等使用 > use Template Engine(like Velocity),render the SQL(not only sql) dynamically via configure file,no framework dependency,it can be used for jdbc,jdbcTemplate, and etc.. ##特性(Feature) * __兼容性强__,为多种模板引擎,提供统一配置方式; * __COMPATIBILITY__,multiple engines of renderer,one way 2 config; * __可读性强__,较程序控制的动态SQL,使用'模板引擎+SQL'的方式,编写的SQL可读性更强,换来较好的维护性; * __READABLE__,compare with using java code,using 'template engine + SQL' make the SQL more readable,which also improving maintenance 4 code; * __可动态替换__,不会出现.class文件替换错误的情况,这代表只要编辑好xml,更新下资源,刷新下页面sql就起效了 (调试神器,(no more hot-swap failed),这需要在配置文件显式申明cmd-col\[doDebug=true],timeCost将有所增加); * __SWAP_DYNAMICALLY__,no more hot-swap failed,it means while u modified config file,upload the resource,refresh the page,the change will appear.(this required declare cmd-col\[doDebug=true] in config file,timeCost will increase); * __可插拔性强__,即便真是因为这个工具出了问题,也不用做框架层次的整改,在相应方法上修改成原来的方法就行了, 调整小(见net.zdsoft.demo.dao.impl.DemoDaoImpl); * __PLUGABLE__,even some problem do apear due 2 this tool,u have not 2 change the hole architecture,just modify the corresponding method(see net.zdsoft.demo.dao.impl.DemoDaoImpl); * __轻量级__,仅仅用来生成SQL语句,不含jdbc执行; * __LIGHT_WEIGHT__,only do the work of render; * __模板语言自定义性强__,可定义模板语言的常用函数,在引擎时渲染时使用,提高重用性(见resources/lib.vm); * __CUSTOMIZE\_THE\_ENGINE__,customize the macro of the template engine is available(see resources/lib.vm) ##用例(Usage) ```xml hello ``` ```java /** * 演示dao * * @author xusk * @Date: 15/12/31 下午3:58 */ public class DemoDaoImpl extends MockDao implements DemoDao { private static final Organizer organizer = new Organizer("/command.xml", "http://ACoinWork.com"); /** * 演示一个dao的方法如何使用 * * @param list * @return */ @Override public List getListByIds(List list) { //实例化渲染上下文 VelocityContext ctx = new VelocityContext(); ctx.put("list", list); //organizer.getResById("cmd1", ctx) //通过cmd[id]与渲染上下文获得渲染后的资源 final List result = query(organizer.getResById("cmd1", ctx)); return result; } } ``` _that`s all.Simple and Useful._ ##类图(DiagramExplanation) ![DiagramExplain](DiagramExplain.png)