@Override
  protected void processTemplates(List<TemplateResource> templateResources, Writer writer)
      throws Exception {

    try {
      String namespace = GetterUtil.getString(get(TemplateConstants.NAMESPACE));

      if (Validator.isNull(namespace)) {
        throw new TemplateException("No namespace specified.");
      }

      SoyFileSet soyFileSet = getSoyFileSet(templateResources);

      SoyTofu soyTofu = soyFileSet.compileToTofu();

      Renderer renderer = soyTofu.newRenderer(namespace);

      renderer.setData(getSoyMapData());

      boolean renderStrict = GetterUtil.getBoolean(get(TemplateConstants.RENDER_STRICT), true);

      if (renderStrict) {
        SanitizedContent sanitizedContent = renderer.renderStrict();

        writer.write(sanitizedContent.stringValue());
      } else {
        writer.write(renderer.render());
      }
    } catch (PrivilegedActionException pae) {
      throw pae.getException();
    }
  }
  public DirectoryHandler(Config config) {
    this.config = config;

    SoyFileSet.Builder builder = new SoyFileSet.Builder();
    builder.add(Resources.getResource(DirectoryHandler.class, "soyweb.soy"));
    SoyFileSet fileSet = builder.build();
    soyWebTemplate = fileSet.compileToTofu();
  }
Beispiel #3
0
 static {
   SoyFileSet.Builder builder = SoyFileSet.builder();
   builder.add(Resources.getResource(ModulesHandler.class, "modules.soy"));
   SoyFileSet fileSet = builder.build();
   TOFU = fileSet.compileToTofu();
 }