Skip to content

Instantly share code, notes, and snippets.

@spg
Created February 6, 2013 15:53
Show Gist options
  • Save spg/4723475 to your computer and use it in GitHub Desktop.
Save spg/4723475 to your computer and use it in GitHub Desktop.
// ------- Supposons le fichier path/to/my/velocity/file.vm -----
// <html>
// $val1
// $val2
// $val3
// </html>
// ==== Option 1 =====
VelocityWrapper vw = velocityWrapperFactory.create("path/to/my/velocity/file.vm");
String output1 = vw.put("val1", "1").put("val2", "2").put("val3", "3").generate(); // le context n'est pas effacé par generate()
String output2 = vw.put("val2", "a").generate();
// ------- output1 -----
// <html>
// 1
// 2
// 3
// </html>
// ------- output2 -----
// <html>
// 1
// a
// 3
// </html>
// ==== Option 2 =====
VelocityWrapper vw = velocityWrapperFactory.create("path/to/my/velocity/file.vm");
String output1 = vw.put("val1", "1").put("val2", "2").put("val3", "3").generate(); // le context est effacé par generate()
String output2 = vw.put("val2", "a").generate();
// ------- output1 -----
// <html>
// 1
// 2
// 3
// </html>
// ------- output2 -----
// <html>
// $val1
// a
// $val3
// </html>
// ==== Option 3 =====
VelocityWrapper vw = velocityWrapperFactory.create("path/to/my/velocity/file.vm");
String output1 = vw.put("val1", "1").put("val2", "2").put("val3", "3").generate();
String output2 = vw.clear().put("val2", "a").generate(); // le context doit être effacé manuellement par l'utilisateur
// ------- output1 -----
// <html>
// 1
// 2
// 3
// </html>
// ------- output2 -----
// <html>
// $val1
// a
// $val3
// </html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment