[stringtemplate-interest] Re: [antlr-dev] crap, we need to fix the map issue with ST

Terence Parr parrt at cs.usfca.edu
Wed Jul 26 14:37:17 PDT 2006


Ok, slight adjustment, must use <aMap.(k)> because k is not the  
literal k--it's a variable that holds the key name:

	public void testMapKeys() throws Exception {
		StringTemplateGroup group =
			new StringTemplateGroup("dummy", ".",  
AngleBracketTemplateLexer.class);
		StringTemplate t =
			new StringTemplate(group,
				"<aMap.keys:{k|<k>:<aMap.(k)>}; separator=\", \">");
		HashMap map = new LinkedHashMap();
		map.put("int","0");
		map.put("float","0.0");
		t.setAttribute("aMap", map);
		assertEqual(t.toString(), "int:0, float:0.0");
	}

Pushed. [change 2833]

Ter



More information about the stringtemplate-interest mailing list