StringTemplate.Net 学习笔记(1):开篇
2010-04-29 14:13
447 查看
简介
StringTemplate(简称ST)是一个基于Java的模板引擎库(已移植到C#、Python、Ruby和Scala),可以用于生成源代码、Web页面、电子邮件或任何其他格式的文本输出。ST不同于其他类似的模板引擎的显著特点是严格执行模型视图分离,尤其擅长多目标代码生成、多种网站风格管理以及网站多语言版本生成等。ST已经应用到许多大型网站中,例如jGuru.com。
ST在.net平台下的最新版本为3.2(版本号3.1.3.6002),这个版本开始使用Antlr3来实现,下载地址为:http://www.stringtemplate.org/download/StringTemplate-3.2-2009-06-28.7z,由于它使用了C#3.0语法,所以只能在.net framework 3.5以上版本运行,可以在http://fisheye2.atlassian.com/browse/antlrcs/Antlr3.StringTemplate找到它的源代码。
如果要在.net framework 1.1/2.0上使用ST,可以选择由Antlr2实现的3.1beta1或3.0.1版本,可以从http://stringtemplate.org/download.html下载(提供了全部源代码)。
ST的资料主要集中在官方网站http://www.stringtemplate.org/的Documentation、Wiki及Articles栏目,中文方面的资料非常欠缺,对于英文比较糟糕的我来说是一件痛苦的事情...
使用
下载StringTemplate-3.2-2009-06-28.7z,在项目里添加引用Antlr3.Runetime.dll、Antlr3.Runetime.Debug.dll、Antlr3.StringTempalte.dll。
话说运行在Release下为什么要引用Antlr3.Runetime.Debug.dll,实在不解!
本文地址:/article/5108224.html
参考:http://www.antlr.org/wiki/display/ST/StringTemplate+3.0+Printable+Documentation
StringTemplate(简称ST)是一个基于Java的模板引擎库(已移植到C#、Python、Ruby和Scala),可以用于生成源代码、Web页面、电子邮件或任何其他格式的文本输出。ST不同于其他类似的模板引擎的显著特点是严格执行模型视图分离,尤其擅长多目标代码生成、多种网站风格管理以及网站多语言版本生成等。ST已经应用到许多大型网站中,例如jGuru.com。
ST在.net平台下的最新版本为3.2(版本号3.1.3.6002),这个版本开始使用Antlr3来实现,下载地址为:http://www.stringtemplate.org/download/StringTemplate-3.2-2009-06-28.7z,由于它使用了C#3.0语法,所以只能在.net framework 3.5以上版本运行,可以在http://fisheye2.atlassian.com/browse/antlrcs/Antlr3.StringTemplate找到它的源代码。
如果要在.net framework 1.1/2.0上使用ST,可以选择由Antlr2实现的3.1beta1或3.0.1版本,可以从http://stringtemplate.org/download.html下载(提供了全部源代码)。
ST的资料主要集中在官方网站http://www.stringtemplate.org/的Documentation、Wiki及Articles栏目,中文方面的资料非常欠缺,对于英文比较糟糕的我来说是一件痛苦的事情...
使用
下载StringTemplate-3.2-2009-06-28.7z,在项目里添加引用Antlr3.Runetime.dll、Antlr3.Runetime.Debug.dll、Antlr3.StringTempalte.dll。
using System; using Antlr3.ST; namespace Chapter01 { class Program { public static void Main(string[] args) { StringTemplate query = new StringTemplate("hi,$name$!"); query.SetAttribute("name", "囧月"); Console.WriteLine(query.ToString()); Console.ReadKey(true); } } }
输出结果:hi,囧月!
话说运行在Release下为什么要引用Antlr3.Runetime.Debug.dll,实在不解!
本文地址:/article/5108224.html
参考:http://www.antlr.org/wiki/display/ST/StringTemplate+3.0+Printable+Documentation
相关文章推荐
- StringTemplate.Net 学习笔记(1):
- StringTemplate.Net 学习笔记(6):自定义输出格式
- StringTemplate.Net 学习笔记(6):自定义输出格式
- StringTemplate.Net 学习笔记(9):深入了解模板组文件
- StringTemplate.Net 学习笔记(11):自定义错误处理
- StringTemplate.Net 学习笔记(2):语法介绍(表格)
- StringTemplate.Net 学习笔记(7):加载模板文件
- StringTemplate.Net 学习笔记(5):条件声明
- StringTemplate.Net 学习笔记(3):表达式元素语法(上)
- StringTemplate.Net 学习笔记(7):加载模板文件
- StringTemplate.Net 学习笔记(8):加载模板组文件
- StringTemplate.Net 学习笔记(4):表达式元素语法(下)
- StringTemplate.Net 学习笔记(总结)
- StringTemplate.Net 学习笔记(3):表达式元素语法(上)
- StringTemplate.Net 学习笔记(5):条件声明
- StringTemplate.Net 学习笔记(10):模板组继承及模板组接口
- StringTemplate.Net 学习笔记(2):语法介绍(表格)
- StringTemplate.Net 学习笔记(4):表达式元素语法(下)
- Asp.net core 学习笔记 ( Smtp and Razor template 电子邮件和 Razor 模板 )
- ADO.NET 学习笔记(一)―― 开篇