`
javamonkey
  • 浏览: 171182 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

beetl 开始翻译成英文文档了,有自愿者么?

阅读更多

 

这是最近几个月beetl 使用者完成的俩个电商网站截图:



最近在做中文翻译成英文以走出国门,没有翻译完,还有30多页了,虽然翻译的蹩脚,但看着已经有点像模像样了,等着慢慢优化,如果有自愿者能帮助,那就更好了

 

Beetl Guid

---Joel Li 2012-6-29

1.      What is Beetl ............................................................................................................ 2

1.1.            What beetl can do for you .......................................................................... 3

2.               Basic Usage......................................................................................................... 3

2.1.            Hello Beetl .................................................................................................. 3

2.2.           Delimiter  of Placeholder and Statment.......................................................... 4

2.3.           Define variable............................................................................................. 5

2.4.           算术表达式 ................................................................................................. 7

2.5.           逻辑表达式 ................................................................................................. 7

2.6.           循环语句 ..................................................................................................... 7

2.7.           条件语句 ..................................................................................................... 9

2.8.           函数调用 ................................................................................................... 10

2.9.           格式化 ...................................................................................................... 10

2.10.         直接调用 class方法和属性 .......................................................................... 11

2.11.         错误处理 ................................................................................................... 11

2.12.         安全输出 ................................................................................................... 12

2.13.         注释 .......................................................................................................... 12

2.14.         其他琐碎功能 ............................................................................................ 13

3.      高级用法 ................................................................................................................. 15

3.1.           总是使用 GroupTemplate............................................................................ 15

3.2.           允许优化,超越其他模板引擎 ................................................................... 16

3.3.           允许 Byte直接输出 .................................................................................... 17

3.4.           自定义函数 ............................................................................................... 18

3.5.           格式化函数 ............................................................................................... 19

3.6.           严格 MVC控制 .......................................................................................... 20

3.7.           虚拟属性 ................................................................................................... 21

3.8.           标签 .......................................................................................................... 21

3.9.           ............................................................................................................. 22

3.10.         空格处理 ................................................................................................... 23

3.11.         自定义错误处理 ........................................................................................ 24

4.      Spring MVC............................................................................................................. 24

4.1.           配置 ViewResolver...................................................................................... 24

4.2.           模板中获取参数 ........................................................................................ 25

5.      Servlet中使用 Beetl............................................................................................. 26

5.1.           配置 Linstener............................................................................................ 26

5.2.           编写 Servlet............................................................................................... 28

6.      附录:扩展包 .......................................................................................................... 28

6.1.           函数 .......................................................................................................... 29

6.2.           格式化函数 ............................................................................................... 29

6.3.           标签 .......................................................................................................... 29

6.4.           Freemarker功能对比 .................................................................................. 30

6.5.           Freemarker性能比较 .................................................................................. 33

6.5.1.        单线程: ............................................................................................ 33

6.5.2.        并发 ................................................................................................... 34

 

1. What is Beetl

Beet l is abbreviation of Bee template language current version is 1.2M1total size 360K (include antlr runtime lib) the features of beetl as following:

1 very simple It is a JavaScript-like grammar with a few symbolAnyone who familiar with java or javascript can master very soon.

2 Full functionality It is fully functional template language, support lots of features which current popular Template engine support ,such as FreeMarder ref 附录freemarker 功能对比

3 extremely high performance If enable compiling template to java class and enable direct byte outputtingthe speed of rendering template is fastest in popular template enginesthe consume of system resource is lower than other template engineref 附录freemarker 功能对比

4 unique features self customized placeholdervirtual attribute for model ,,self customized function, formatter, Tag and safe outputing etc these features are easy understand and can solve many template rendering issue

5 Support both MVC and strict MVC you can  forbid  evaluate expression  and complicated logic expression if you think these should be put in logic layer not view layerplease refer strictly enforces model-view separation

6 can be easily integrated with other Web Framework, such as Spring, Servlet .etc.   in 1 minute

 

1.1.    What beetl can do for you

As template language, you can make use of it in any place of   MVC  base on Java such as Web page ,Code generation. You also can learn Antlr if you are interesting in it  because Beetl is a template language based on Antlr

2.   Basic Usage

2.1.    Hello Beetl

package org.bee.tl.samples;

 

import org.bee.tl.core.GroupTemplate;

import org.bee.tl.core.Template;

 

public class Helloworld

{

       public static void main(String[] args) throws Exception

       {

 

              String input = "hello,${name}!" ;

              GroupTemplate group = new GroupTemplate();/1

              Template template = group.getStringTemplate(input); /2

              template.set( "name" , "beetl" );/3

              String output = template.getTextAsString();/4

              System. out .println(output);

       }

}

 

1 Create GroupTemplate with empty constructor  so it can make a String Template In  most case template is file, so you can create GroupTemplate with the file root of templates, for example: GroupTemplate  group = new GroupTemplate(“c:\templateroot”)

2 In this case , the template is a string "hello,${name}!" so, you can call method getStringTemplate to get Template instance. ${ ” “} are placeholder in templateThe expression in placeholder is evaluated and output to the StringWriter

If template is a file, you must call method getFileTemplate pass   a relative path to root as the parameter. For examples:

GroupTemplate  group = new GroupTemplate(“c:/templateroot”)
/* c:/templateroot/user/userList.html is template file */
Template template  = group.getFileTemplate(“/user/userList.html”);.

3  template.set( String key , Object value ) just define Template variable which can be referenced in any place of  Template the parameter String is variable name followed Java(Javascript) name convention ,the parameter Object is value of variable which can be any java Object instance.   You can reference object attribute by using “.” For example  ${user.name},If Objec is array or subclass of java.util.List or you can refrence item using index,such as ${user.friends[0]},if Object is subclass of Java.util.Map you can refrence the value by key,for example ${books[ thinking in java].author}

4 you can get the output by call  template.getTextAsString() or template.getText(Writer) or   template.getText(OutputStream os) NOTE :only  OutputStream can be used if you using advance features direct byte output )。In this examplethe output is hello,beetl!

2.2. Delimiter   of Placeholder and Statment

By default “<%” is the start delimiter of Statement%> is the end delimiter of statement

<% for(user in userList){ %>

hello,${user.name}

<%}%>

By default, the Beetl expression between   "${" and "}" will be evaluated and output.

${users[index]}

Beetl can define delimiter of placeholder and statement as your favorite. For example you can define <!--:  --> as your delimiter of statement in HTML template.

public static void main(String[] args) {

        GroupTempate group = new GroupTemplate(root);

      group.setStatementStart("<!--:");

      group.setStatementEnd("-->");

      group.setPlaceholderStart("${");

      group.setPlaceholderStart("}");

      // or call config method for simplify
      //group.config("<!--","-->","${","}");

 

       File child = …..

       Template template =group.getFileTemplate(child);

   

      String output = template.getTextAsString();

 

 

}

In this case, Beetl can parser the following template  

<!--: var name= lijz;

var greeting = morning;

-->

<p>Hello ${name} ${greeting~}</p>

Note: the default delimiter of statement are “<%” “%>” ,the default delimiter of placeholder are “${“  “ }”

2.3.   Define variable

Beetl have two kinds of variable.one is global variable which can be referred in any place( include child template) the global variable is readonly and set value by call template.set(String,Object) in Java codeAnother variable is   temporary variable which only defined in Template   such as

<%var name='lijz',loopCount=100+other ,girlName;%>

(The keyword “var” is necessary , it’s differ from    javascript) .

There is no scope for temporary variable( like java) the ,the following code will get error of  “variable has defined “name”

<%var name= lijz,i=1; %>

<%if(i>=1){%>

  <%var name='lucy';%>

  Hello,${name}

<%}%>

  Beetl also support JSON variable like javascript. It’s intuitive but I recommend model is defined in business layer not view layer

<% var usersList=[{ name:lijz,age:18},{name:lucy,age:16}];%>

She’s ${userList[1][ name]}

  As above template fragment ,there is two item in array “usersList” each item include a Mapso the value of key “name” is “lucy” for the second item .

Beetl always wrap number object (int,float,double,Bigdecimal) as BeeNumber to support large scale calculation, so don’t worry the high precision computation .I recomand DO not do calculation if this is a part of business logic since we must try to flow MVC principle.

NOTE

The variable name is followed Java(JavaScript) name convention, but can not define the variable name start with “__” since it’s for internal using.

 

 

  • 大小: 85.7 KB
  • 大小: 37.1 KB
分享到:
评论

相关推荐

    毕业设计javassm珠江学院大学生自愿者服务网+vue源码含文档含教程

    毕业设计javassm珠江学院大学生自愿者服务网+vue源码含文档含教程 后台是ssm框架,后台的页面是vue,前端页面是html,数据库mysql,jdk1.8,开发工具用ecplise、myecplise、sts、idea都可以 珠江学院大学生自愿者...

    IEEE829测试文档标准

    IEEE829测试文档标准是软件测试领域的一个重要文档规范,它详细描述了一套基础软件测试文档的格式和内容。这个标准由IEEE计算机协会软件工程技术委员会赞助,并在1998年9月16日获得了IEEE-SA标准委员会的批准。IEEE...

    “服务之心”:大学生自愿者服务网系统的功能开发

    为了迎合这一需求,珠江学院大学生自愿者服务网系统应运而生,旨在通过网络提供便捷的志愿服务信息。 本文详细介绍了珠江学院大学生自愿者服务网系统的开发过程。系统基于SSM框架构建,融合了Vue技术,并采用MySQL...

    自愿者培训心得.doc

    自愿者培训心得.doc

    珠江学院大学生自愿者服务网站 SSM毕业设计 附带论文.zip

    本文档是关于“珠江学院大学生自愿者服务网站”的SSM(Spring, SpringMVC, MyBatis)框架毕业设计项目,它是一个完整的网站建设项目,旨在为珠江学院的大学生提供一个自愿者服务平台。该平台不仅能够让学生更好地...

    H264官方文档(中文).pdf

    文档强调了遵守H.264标准是自愿的,但在某些情况下,可能包含强制性条款以保证互操作性和适用性。 此外,文档中还提出了关于知识产权的问题,指出使用H.264标准可能会涉及已申报的知识产权,而国际电信联盟(ITU)...

    基于ssm+vue珠江学院大学生自愿者服务网.zip

    【标题】"基于ssm+vue珠江学院大学生自愿者服务网"是一个综合性的项目,它融合了多种技术,旨在为珠江学院的大学生提供一个志愿服务平台。这个项目利用了Java的SSM(Spring、SpringMVC、MyBatis)框架与前端的Vue.js...

    【计算机程序设计项目源码】ssm706珠江学院大学生自愿者服务网+vue.zip

    本压缩包文件是《计算机程序设计项目源码》的一部分,包含了ssm706珠江学院大学生自愿者服务网的项目源代码。该项目采用了Vue前端框架和SSM(Spring、SpringMVC、MyBatis)后端技术栈,适用于学习Java Web开发、熟悉...

    论文研究-社会责任信息披露提高企业的市场表现了么?.pdf

    且社会责任报告的质量与市场的表现有一定的正相关性.研究表明社会责任报告整体质量偏低、公众的企业社会责任意识较弱是制约资本市场对企业社会责任信息披露评价的主要因素.本文的研究发现为企业与监管政策从一味追求...

    ssm珠江学院大学生自愿者服务网+vue.zip

    而项目名称“daxueshengziyuanzhefuwuwang”直接翻译为“大学生志愿者服务网”,清晰地表达了该项目的服务对象和核心功能。 ssm珠江学院大学生志愿者服务网项目是一个具有实用价值和教学意义的综合案例,它不仅能够...

    ssm9706珠江学院大学生自愿者服务网+vue.zip

    本项目“ssm9706珠江学院大学生自愿者服务网+vue”正是应这样的需求而生,它是一个专门为大学生志愿者服务活动打造的信息管理平台。本平台的技术选型结合了Java语言的稳定性和高效性,利用SSM(Spring、SpringMVC、...

    珠江学院大学生自愿者服务网+vue

    珠江学院大学生志愿者服务网结合了Vue框架进行开发,Vue是一种轻量级的前端JavaScript框架,它以数据驱动和组件化的思想设计,使得开发者能够更加高效地构建用户界面。该服务网以Java作为后端开发语言,Java是广泛...

    数据库课程设计ssm706珠江学院大学生自愿者服务网+vue.sql

    数据库课程设计ssm706珠江学院大学生自愿者服务网+vue.sql

    ssm706珠江学院大学生自愿者服务网+vue.rar

    根据提供的文件信息,本项目名称为“ssm706珠江学院大学生自愿者服务网+vue”,是一个基于SpringBoot、Java和Vue技术栈构建的网络应用。该项目的开发采用了前后端分离的架构方式,其中Vue.js负责前端的动态交互界面...

    学院大学生自愿者服务网站 SSM毕业设计 源码+数据库+论文(JAVA+SpringBoot+Vue.JS).zip

    论文部分则详细介绍了整个项目的开发过程、设计理念、技术选型、系统架构以及实现的功能等,是学习者了解项目全貌的重要文档。 另外,项目还提供了启动教程链接,通过视频教程的方式,指导用户如何快速部署和启动这...

    h264标准文档(中文版)

    ### H.264标准文档(中文版)关键知识点概览 #### 1. H.264标准的背景与目的 H.264,作为一项由国际电信联盟(ITU-T)制定的视频编码标准,是基于先前的视频编码标准(H.261、H.262和H.263)发展而来的,旨在满足...

    英语教师课堂用语.pdf

    12. 使用母语/目标语言:老师会要求学生将某些内容翻译成母语或目标语言,“Put it/them into Chinese/English.”(请把它们翻译成中文/英文。) 13. 物品要求:老师会要求学生拿出或使用特定物品,如“Please open...

    ieee 1394 文档资料 英文

    4. **标准化进程**:修正案强调了IEEE标准文档的开发是在IEEE社会和IEEE-SA标准委员会的协调下进行的,参与标准制定的成员是自愿服务且无薪酬的专家。这些标准代表了IEEE内部广泛的专业知识以及外部参与者的意见和...

    基于java的学院大学生自愿者服务网站设计与实现.docx

    鉴于此,本文提出的基于Java的学院大学生自愿者服务网站的设计与实现,具有非常重要的现实意义和应用价值。 本项目的设计目标是建立一个既能展示学院大学生志愿者服务动态,又能为志愿服务活动提供网络化管理的平台...

    毕业设计-ssm框架珠江学院大学生自愿者服务网+vue+论文+源代码等完整资料.zip

    本项目为“珠江学院大学生自愿者服务网”,专为计算机相关专业学生及Java学习者设计,提供毕业设计、课程设计的高分资源。项目源码、数据库脚本及开发说明等一应俱全,并附论文参考,可直接用于毕设。 项目采用...

Global site tag (gtag.js) - Google Analytics