1 Star 0 Fork 5

framegroup / zhiqim_zml

forked from 知启蒙 / zhiqim_zml 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

什么是“ZML”?


      ZML(Zhiqim Markup Language)即“知启蒙标记语言”,是知启蒙定义的、类似于Java & Javascript语法的语句和表达式,通常和XML/HTML混编在一起形成的一种新的标记语言。ZML力求简单易用,目前支持常用的十二种标记语句和五十种表达式,在知启蒙框架体系中被用来代替JSP。


什么是“ZML引擎”?


      ZML引擎(ZhiqimZML)即“知启蒙标识语言引擎”,是实现ZML规范的引擎系统。支持两种ZML加载方式(按文件目录和按类路径)、能够在ZML文件改动后立即发现并在触发时重新加载、并提供详细的“表达式合并运算优先级”、“变量多维作用域”和“无障碍访问Java代码”,以及设置上下文作用域的配置模板、对模板进行缓存等特性。


“ZML引擎”有哪些优点?


1、ZhiqimZML仅依赖JDK1.7+和ZhiqimKernel。15年的坚持,值得信赖。
2、ZhiqimZML支持十二种语句和五十种表达式基本覆盖业务操作,是知启蒙WEB容器的重要组成部分,在ZhiqimDK家族中占据非常重要的位置。
3、对比国外模板引擎Freemarker和Velocity,ZhiqimZML更有优势,结合知启蒙微内核的大量工具类(如Strings/Validatest),使得ZhiqimZML可无障碍访问Java代码,称之为Java的标识语言都不为过。
4、最后自荐一下,比Spring更轻量、更齐全的J2EE框架 zhiqim 正式开源啦,不服来试用。


最简单的ZML引擎使用方法


1、准备好一段符合ZML规格的字符串,和一个变量表,即可解析出结果。
2、支持全局变量表中@AnAlias注解别名表和预定义Java类名的静态变量和静态方法调用。
3、详细见org.zhiqim.zml.Zmls静态类中的方法,如下提供的parse方法。

ZML支持的十二种语句                                                                                          前往五十种表达式


一、变量定义语句(_Var)

<#var name = "知启蒙模板引擎"/>

表示定义变量name的值为“知启蒙模板引擎”。

二、函数定义语句(_Function)

<#function functionName(param1, param2)>
    <div>param1 = ${param1}</div>
    <div>param2 = ${param2}</div>
</#function>

三、文件包含语句(_Include)

<#include "/zml/inc.zml"/>

表示包含文件“/zml/inc.zml”的内容到该页面中。

四、判断语句(_If)

<#if (!Validates.isEmpty(name) && name.startWith("知启蒙"))>
    ${name}
</#if>

五、遍历语句(_For)

<#for (var item : list)>
    <#if (Validates.isNotEmpty(item))>
        ${item}
    </#if>
</#for>

简写:

<#for item : list>
    <#if (Validates.isNotEmpty(item))>
        ${item}
    </#if>
</#for>

六、拦截器语句(_Interceptor)

<#interceptor "chkLogin"/>

拦截器语句用于在执行之前判断是否支持定义的参数的值,如"chkLogin"表示是一个拦截器名称

七、显示结果语句(_Echo)

显示结果语句是通过连接、计算和合并的方式执行多个表达式,得到执行结果,然后把结果显示在页面上,值为(null)不显示结果,如:

<#var name = "知启蒙"/>

${name} 表示执行表达式name,得到结果“知启蒙”

${name + "引擎"} 表示执行表达式name + "引擎",得到结果“知启蒙引擎”

${functionName(name, "edf")} 表示调用函数并显示结果

${Strings.trimLeft(name, "知")} 表示类Strings的trimLeft方法,显示结果“启蒙”

八、显示格式化结果语句(_Format)

显示格式化结果语句是通过连接、计算和合并的方式执行多个表达式,得到执行结果,值为(null)不显示结果,<br>
并对其他Zmls.format(zml)格式化,对<,>,\",\',${,@{,#{格式化,保证浏览器解释成字符串而不是ZML代码,如:

<#var name = "知${abc}启蒙"/>
#{name} 表示执行表达式name,得到结果是“知&#x24;{abc}启蒙”,$符号转为&#x24

#{name + "引\"擎"} 表示执行表达式name + "引\"擎",得到结果“知&#x24;{abc}启蒙引&quot;擎”,$符号转为&#x24,引号变成&quot;

#{functionName(name, "edf")} 表示调用函数并显示结果

#{Strings.trimLeft(name, "知")} 表示类Strings的trimLeft方法,显示结果“&#x24;{abc}启蒙”

九、调用不显示结果语句(_Call)

调用语句是通过连接、计算和合并的方式执行多个表达式,执行,但不显示结果到页面上,如:

@{System.out.println("显示信息到控制台,不是显示到页面")} 表示执行System.out.println();

十、返回语句(_Return)

返回语句应用于标识当前页执行结束,直接返回,和函数function中返回值:

<#if Validates.isEmpty(sessionKey)>
    <#return/>
</#if>

<#function functionName(param1, param2)>
    <#var ret = param1+param2/>
    <#return ret/>
</#function>

十一、继续语句(_Continue)

继续语句应用于_For语句中,表示结束当次处理,继续下一次:

<#for item : list>
    <#if (Validates.isNotEmpty(item))>
        <#continue/>
    </#if>
</#for>

十二、中断语句(_Break)

<#for item : list>
    <#if (Validates.isNotEmpty(item))>
        <#break/>
    </#if>
</#for>

常用的ZML页面和ZML配置模板


常用的ZML页面 常用的ZML配置模板

强大的ZML引擎解析文件


1、支持对文件目录/类路径加载配置定义的变量和函数到上下文变量表中,支持根据path查找ZML文件加载。
2、支持多个组件加载器,依次查找组件配置模板中定义的变量和函数到上下文变量表,和根据path查找的ZML文件加载。
3、支持自定义设置全局变量。
4、支持对ZML文件监视,有变动立即知晓,并在被触发时加载文件,如是配置模板会回调通知。
5、支持对ZML文件缓存,并提供缓存参数maxIdleTime/maxKeepTime。
参数 参数类型 描述
notice ZmlVarNotice 设置模板变量变动通知,当/conf/config.zml有变动并触发时回调doUpdate方法
encoding String 模板加载编码
maxIdleTime int 模板最大空闲时长,建议1小时
maxKeepTime int 模板最大保持时长,建议24小时
isAscQuery boolean 当有组件配置模板时,是否按顺序查找
patterns String 模板匹配模式,默认*.zml,*.htm
loader ClassZmlLoader
FileZmlLoader
设置根配置模板加载器,类路径/目录
cLoaderMap ClassZmlLoader 组件配置模板加载器,类路径/目录,支持多个,
通过addComponentZmlLoader()添加
globalMap HashMap 全局变量表,通过addGlobalVariable添加
//先创建ZML引擎,可以保存起来
ZmlEngine engine = new ZmlEngine();
engine.setFileZmlLoader(new File("./resource"));
engine.setConfigZml("/conf/config.zml");

//调用和解析ZML文件
Zml zml = engine.getZml("/zml/abc.zml");
HashMapSO variableMap = new HashMapSO();
variableMap.put("abc", "知启蒙");
variableMap.put("def", "标识语言");
variableMap.put("isAbc", false);

String result = Zmls.parese(zml, variableMap);

知启蒙技术框架与交流


知启蒙技术框架架构图

QQ群:加入QQ交流群,请点击【458171582】

教程:欲知更多知启蒙标识语言,【请戳这里】

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. [http://fsf.org/] Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

ZML(Zhiqim Markup Lanuage)即“知启蒙标记语言”,既继承了Java模板引擎(Freemarker/Velocity)的无需编译的解释特性,又实现了JSP的无障碍访问Java代码的能力,并且规范了标签命名(完全向Java & Javascript语法靠拢),和HTML/XML融合在一起更易理解和直观,学习和使用绝对更轻便。因此我们不再称之为模板引擎,而称之为标记语言。目前支持十二种语句(var、function、if、for、include、echo、return、continue、break……),五十种表达式。 展开 收起
Java
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/framegroup/zhiqim_zml.git
git@gitee.com:framegroup/zhiqim_zml.git
framegroup
zhiqim_zml
zhiqim_zml
master

搜索帮助