简体   繁体   English

使用Stringtemplate通过Maven从模板生成HTML页面

[英]Using Stringtemplate for generating HTML pages from templates with Maven

I have a relatively simple web app, which uses basic HTML pages with Ajax (using jQuery, bit of Javascript) to access data from a web service and render it. 我有一个相对简单的Web应用程序,它使用带有Ajax的基本HTML页面(使用jQuery,Java语言的一部分)来访问Web服务中的数据并进行渲染。 So far so good. 到现在为止还挺好。 But since there are commonalities between the pages (the usual stuff, headers etc), I would love to templatize. 但是由于页面之间存在共性(常用的东西,标题等),所以我希望将其模板化。 But given static nature of templating I would like to do this as part of the build process and not dynamically, just so that what is deployed for GUI is strictly just bunch of static resources (HTML, css, javascript libs). 但是考虑到模板的静态性质,我想在构建过程中进行此操作,而不是动态进行,只是为了GUI部署的严格来说只是一堆静态资源(HTML,css,javascript库)。

Stringtemplate (http://www.stringtemplate.org/) looks like a very elegant templating engine that would probably work well. Stringtemplate(http://www.stringtemplate.org/)看起来像一个非常优雅的模板引擎,可能会很好地工作。 But while I could easily write bit of Java to invoke it, I was hoping to find an existing Maven plug-in that would allow me to automate the whole building and packaging process. 但是,尽管我可以轻松地编写一些Java来调用它,但我希望找到一个现有的Maven插件,该插件可以使我自动完成整个构建和打包过程。 I wasn't able to find such thing, but was hoping that others might know of something similar? 我找不到这种东西,但是希望其他人可能知道类似的东西吗?

UPDATE: looks like while Stringtemplate has its benefit, some things are not particularly easy with it; 更新:看起来虽然Stringtemplate有其优势,但有些事情并不容易。 say, inclusion of HTML snippet files. 例如,包含HTML代码段文件。 So I am thinking of looking at other options (FreeMarker, MiniTemplator, maybe even Velocity) 所以我在考虑其他选择(FreeMarker,MiniTemplator甚至Velocity)

Ok, looks like there wasn't. 好的,好像没有。

I did create a new Github project, maven-stringtemplate-plugin , for what that's worth, although I am not actually sure if I will use Stringtemplate for this particular purpose. 我确实创建了一个新的Github项目maven-stringtemplate-plugin ,尽管实际上我不确定是否会为此目的使用Stringtemplate,但确实这样做。 But it might work for other kinds of use cases. 但它可能适用于其他类型的用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM