stringtemplate

Linking Xtext with StringTemplate code generator

霸气de小男生 提交于 2019-12-04 14:34:56
问题 In my current project, I am trying to link the DSL specification written in xtext and code generator written in StringTemplate. for instance, the syntax of my DSL specification is as follows. I am entering this information through nice editor facilities provided by xText. structs: TempStruct tempValue : double; unitOfMeasurement : String; abilities : sensors: TemperatureSensor generate tempMeasurement : TempStruct; attribute responseFormat : String; The grammar of above mentioned DSL

Better template language needed [closed]

非 Y 不嫁゛ 提交于 2019-12-04 11:06:51
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Yes, I know that this has been asked before. But most of the questions were two years ago, and there's got to be a better answer today. I need a template language for rendering HTML. Requirements: Must be callable from Java. Must not be Freemarker, Velocity, or StringTemplate. We've been using Freemarker for a

Stringtemplate compare strings does not work

蹲街弑〆低调 提交于 2019-12-04 03:25:57
问题 Can someone explain why this does not work ? StringTemplate query = new StringTemplate("hello " + "$if(param==\"val1\")$" + " it works! " + "$endif$ " + "world"); query.setAttribute("param", "val1"); System.out.println("result: "+query.toString()); It throws eval tree parse error :0:0: unexpected end of subtree at org.antlr.stringtemplate.language.ActionEvaluator.ifCondition(ActionEvaluator.java:815) at org.antlr.stringtemplate.language.ConditionalExpr.write(ConditionalExpr.java:99) 回答1: ST

What is the best way to ensure HTML entities are escaped in StringTemplate

試著忘記壹切 提交于 2019-12-03 22:25:18
问题 Assuming the following string template, is being given a list of Java Bean objects: <ul>$people:{p|<li>$p.name$ $p.email</li>}$</ul> ie the list of people might contain Person objects which you may or may not have the ability to enhance/extend: class Person { .... public getName() { ... } public getEmail() { ... } } The getName() and getEmail() methods don't return sanitised (escaped html entities). How do you get around this? 回答1: You may use a custom renderer, for example: public static

Why StringTemplate could be slow?

橙三吉。 提交于 2019-12-03 21:16:05
问题 I'm using StringTemplate as view layer for my web application. Recently I've measured how much time is spent rendering pages and it's around 50ms for simple pages and 500ms for complex pages. This is too much for my needs, so I'm looking for a way to improve ST's performance. How can I do this? Most of the time is consumed by the StringTemplate.toString method, so it's not a cache problem. I actively use anonymous templates and included templates - could this be the cause? 回答1: use write()

Which Java MVC frameworks integrate easily with StringTemplate?

别等时光非礼了梦想. 提交于 2019-12-03 10:14:33
It's hard to see how StringTemplate integrates easily (or not) with popular Java web MVC frameworks. Which Java MVC frameworks integrate easily with StringTemplate? A good answer: mentions one solution to integrate with a framework, includes a link to something useful and applicable, like: a tutorial , or documentation , or a reference to source code : free , and open source or public domain . Readers/Voters , please vote for a solution if you know it's true and great. In the scope of this question, I am not interested in any other templating engine than StringTemplate . I've gotten

What are the main differences between StringTemplate and FreeMarker?

旧时模样 提交于 2019-12-03 08:17:04
问题 The net seems to be full of comparisons between Velocity and FreeMarker, and they seem to be reasonably equivalent. But there seems to be almost no comparisons between StringTemplate and FreeMarker! So, what are the main differences between StringTemplate and FreeMarker? My usage for them would be to generate HTML pages only. Out of the two, I would've expected FreeMarker to be the more suitable and more capable, as that seems to the more common one - but through a quick glance it seems that

Better template language needed [closed]

爱⌒轻易说出口 提交于 2019-12-03 06:59:58
Yes, I know that this has been asked before . But most of the questions were two years ago, and there's got to be a better answer today. I need a template language for rendering HTML. Requirements: Must be callable from Java. Must not be Freemarker, Velocity, or StringTemplate. We've been using Freemarker for a year, and it's too slow. It consumes 50% of our CPU cycles under load. Velocity is worse than Freemarker, and StringTemplate has got its own issues. It must consume JSON, or its Java equivalent, i.e. Maps, Lists, and primitives. I'm starting to get Node.js envy. There has been a ton of

使用线程池+内存队列实现异步处理业务问题

。_饼干妹妹 提交于 2019-12-03 02:43:45
背景 当系统中的业务存在大量的相同任务(比如发送大量邮件),并且每个任务花费的时间也比较长,前端需要较快 的响应,针对这种需求,我们可以采用消息队列进行异步通知,同时也可以采用线程池+内存队列实现异步通知,处理业务问题。 代码实现 以下采用发送邮件作为demo 邮箱实体类 @Data public class Email implements Serializable { private static final long serialVersionUID = 1L; /** * 自增主键 */ private Long id; /** * 接收人邮箱(多个逗号分开) */ private String receiveEmail; /** * 主题 */ private String subject; /** * 发送内容 */ private String content; /** * 模板 */ private String template; /** * 发送时间 */ private Timestamp sendTime; } 邮件队列 public class MailQueue { //队列大小 static final int QUEUE_MAX_SIZE = 1000; static BlockingQueue<Email> blockingQueue = new

使用线程池+内存队列实现异步处理业务问题

人盡茶涼 提交于 2019-12-03 02:28:10
背景 当系统中的业务存在大量的相同任务(比如发送大量邮件),并且每个任务花费的时间也比较长,前端需要较快 的响应,针对这种需求,我们可以采用消息队列进行异步通知,同时也可以采用线程池+内存队列实现异步通知,处理业务问题。 代码实现 以下采用发送邮件作为demo 邮箱实体类 @Data public class Email implements Serializable { private static final long serialVersionUID = 1L; /** * 自增主键 */ private Long id; /** * 接收人邮箱(多个逗号分开) */ private String receiveEmail; /** * 主题 */ private String subject; /** * 发送内容 */ private String content; /** * 模板 */ private String template; /** * 发送时间 */ private Timestamp sendTime; } 邮件队列 public class MailQueue { //队列大小 static final int QUEUE_MAX_SIZE = 1000; static BlockingQueue<Email> blockingQueue = new