package com.javahonk;

import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

public class IterateMapVelocityTemplate {

	public static void main(String[] args) {
		
		VelocityEngine ve = new VelocityEngine();
		ve.init();
		Template t = ve.getTemplate("./src/main/resources/templates/SampleRenderMap.vm");
		VelocityContext vc = new VelocityContext();
		List<Map<String, Object>> bar = new ArrayList<Map<String, Object>>();
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("Test", "Value1");
		data.put("Tes2", "Value2");
		bar.add(data);
		vc.put("bar", bar);
		StringWriter sw = new StringWriter();
		t.merge(vc, sw);
		System.out.println(sw);
	}

}
