You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by GitBox <gi...@apache.org> on 2021/09/14 09:27:40 UTC

[GitHub] [velocity-engine] xiaoma20082008 opened a new pull request #25: refactor the velocity with more scalable api and spi

xiaoma20082008 opened a new pull request #25:
URL: https://github.com/apache/velocity-engine/pull/25


   I want to refactor the velocity with a more scalable API (for Users) and SPI (for Developers), but I don't know whether it's needed, So I created this pr for ensure it (Please tell me if you need otherwise please close this pr, Thank you! ).
   
   The target is: 
   1. compile the template(*.vm) to a java class(*.java), also provide a interpreter like now.
   2. the template#render will compile the generated java code to a java class and execute it.
   
   The sample usage For User:
   
   ```java
   Template template = VelocityEngine.getTemplate(name, locale, encoding);
   template.render(context, writer);
   ```
   
   Sample Implementation is:
   ```java
   Template getTemplate(String name, Locale locale, String encoding) {
     // 0. cache
     Resource r = cache.get(name);
     // 1. load (the loader maybe is ClasspathLoader, FileLoader, JarLoader... )
     r = loader.load(name, locale, encoding);
     // 2. read a .vm file to string with encoding
     String source = r.getSource();
     // 3. convert xxs characters
     source = converter.convert(name, source);
     // 4. compile
     Class<?> templateClass = compiler.compile(source); // maybe a CompiledTemplate or a InterpretedTemplate
     // 5. create template instance
     return templateClass.getConstructor().newInstance();
   }
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[GitHub] [velocity-engine] AnthonyJClink commented on pull request #25: refactor the velocity with a more scalable api and spi interfaces

Posted by GitBox <gi...@apache.org>.
AnthonyJClink commented on pull request #25:
URL: https://github.com/apache/velocity-engine/pull/25#issuecomment-921196766


   This api looks alot like handlebars. this is pretty slick.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[GitHub] [velocity-engine] xiaoma20082008 commented on pull request #25: refactor the velocity with a more scalable api and spi interfaces

Posted by GitBox <gi...@apache.org>.
xiaoma20082008 commented on pull request #25:
URL: https://github.com/apache/velocity-engine/pull/25#issuecomment-919669259


   > Nice idea, but we won't introduce another logging abstraction. We have replaced log chutes with SLF4J for very good reasons. Drop that part please.
   
   Got it, Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org