SoyTemplate extends BaseTemplate { @Override protected void processTemplate( TemplateResource templateResource, Writer writer) throws Exception { String namespace = GetterUtil.getString( get(TemplateConstants.NAMESPACE)); if (Validator.isNull(namespace)) { throw new TemplateException("Namespace is not specified"); } SoyTemplateResource soyTemplateResource = null; if (templateResource instanceof SoyTemplateResource) { soyTemplateResource = (SoyTemplateResource)templateResource; } else { soyTemplateResource = _soyTemplateResourceFactory.createSoyTemplateResource( Collections.singletonList(templateResource)); } SoyTofuCacheBag soyTofuCacheBag = getSoyTofuCacheBag( soyTemplateResource); SoyTofu soyTofu = soyTofuCacheBag.getSoyTofu(); SoyTofu.Renderer renderer = soyTofu.newRenderer(namespace); renderer.setData(_soyContextImpl.createSoyTemplateRecord()); renderer.setIjData(_soyContextImpl.createInjectedSoyTemplateRecord()); Optional<SoyMsgBundle> soyMsgBundle = getSoyMsgBundle( soyTemplateResource.getTemplateResources(), soyTofuCacheBag.getSoyFileSet(), soyTofuCacheBag); if (soyMsgBundle.isPresent()) { renderer.setMsgBundle(soyMsgBundle.get()); } boolean renderStrict = GetterUtil.getBoolean( get(TemplateConstants.RENDER_STRICT), true); if (renderStrict) { SanitizedContent sanitizedContent = renderer.renderStrict(); writer.write(sanitizedContent.stringValue()); } else { writer.write(renderer.render()); } } SoyTemplate(
		SoyTemplateResource soyTemplateResource, Map<String, Object> context,
		SoyTemplateContextHelper templateContextHelper,
		SoyTofuCacheHandler soyTofuCacheHandler,
		SoyTemplateResourceFactory soyTemplateResourceFactory,
		boolean restricted); @Override Object compute(
		String key,
		BiFunction<? super String, ? super Object, ?> remappingBiFunction); @Override Object computeIfAbsent(
		String key, Function<? super String, ?> mappingFunction); @Override Object computeIfPresent(
		String key,
		BiFunction<? super String, ? super Object, ?> remappingBiFunction); @Override void forEach(BiConsumer<? super String, ? super Object> action); @Override Object getOrDefault(Object key, Object defaultValue); @Override Object merge(
		String key, Object value,
		BiFunction<? super Object, ? super Object, ?> remappingBiFunction); @Override void prepare(HttpServletRequest httpServletRequest); @Override Object putIfAbsent(String key, Object value); @Override boolean remove(Object key, Object value); @Override Object replace(String key, Object value); @Override boolean replace(String key, Object oldValue, Object newValue); @Override void replaceAll(
		BiFunction<? super String, ? super Object, ?> function);  }
@Test public void testProcessTemplateWithInjectedData() throws Exception { SoyTemplate soyTemplate = _soyTestHelper.getSoyTemplate("ijdata.soy"); soyTemplate.put("namespace", "soy.test.ijdata"); soyTemplate.put( SoyTemplateConstants.INJECTED_DATA, HashMapBuilder.<String, Object>put( "hasData", true ).build()); UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); soyTemplate.processTemplate(unsyncStringWriter); Assert.assertEquals( "Injected Data: true", unsyncStringWriter.toString()); }