Пример #1
0
 protected Writer handleFunction(Writer writer, Function function, Object[] scopes) {
   StringWriter sw = new StringWriter();
   runIdentity(sw);
   Object newtemplate = function.apply(sw.toString());
   if (newtemplate != null) {
     if (function instanceof TemplateFunction) {
       String templateText = newtemplate.toString();
       Mustache mustache = cf.getTemplate(templateText);
       if (mustache == null) {
         mustache =
             cf.compile(new StringReader(templateText), tc.file(), tc.startChars(), tc.endChars());
         cf.putTemplate(templateText, mustache);
       }
       writer = mustache.execute(writer, scopes);
     } else {
       try {
         writer.write(newtemplate.toString());
       } catch (IOException e) {
         throw new MustacheException("Failed to write function result", e);
       }
     }
   }
   return writer;
 }
Пример #2
0
 public IterableCode(
     TemplateContext tc, DefaultMustacheFactory cf, Mustache mustache, String variable) {
   super(tc, cf.getObjectHandler(), mustache, variable, "#");
   this.cf = cf;
   les = cf.getExecutorService();
 }
Пример #3
0
 protected Writer writeTemplate(Writer writer, String templateText, Object[] scopes) {
   return cf.getFragment(new FragmentKey(tc, templateText)).execute(writer, scopes);
 }
Пример #4
0
 public ValueCode(
     TemplateContext tc, DefaultMustacheFactory df, String variable, boolean encoded) {
   super(tc, df, null, variable, "");
   this.encoded = encoded;
   les = df.getExecutorService();
 }