Java Code Examples for com.google.clearsilver.jsilver.precompiler.PrecompiledTemplateLoader

Following code examples demonstrate how to use com.google.clearsilver.jsilver.precompiler.PrecompiledTemplateLoaderfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.google.clearsilver.jsilver.precompiler.PrecompiledTemplateLoaderand various code implementation of this class.

  public JSilver(ResourceLoader defaultResourceLoader, JSilverOptions options) {
    options = options.clone();

    this.defaultResourceLoader = defaultResourceLoader;
    this.dataFactory =
        new HDFDataFactory(options.getIgnoreAttributes(), options.getStringInternStrategy());
    this.options = options;

    int bufferSize = options.getInitialBufferSize();
    if (options.getUseOutputBufferPool()) {
      outputBufferProvider = new ThreadLocalOutputBufferProvider(bufferSize);
    } else {
      outputBufferProvider = new InstanceOutputBufferProvider(bufferSize);
    }

    TemplateFactory templateFactory = new LoadingTemplateFactory();

    templateFactory = setupOptimizerFactory(templateFactory);

    TemplateLoader templateLoader;
    List<DelegatingTemplateLoader> delegatingTemplateLoaders =
        new LinkedList<DelegatingTemplateLoader>();
    AutoEscapeOptions autoEscapeOptions = new AutoEscapeOptions();
    autoEscapeOptions.setPropagateEscapeStatus(options.getPropagateEscapeStatus());
    autoEscapeOptions.setLogEscapedVariables(options.getLogEscapedVariables());
    if (options.getCompileTemplates()) {
      TemplateCompiler compiler =
          new TemplateCompiler(templateFactory, globalFunctions, autoEscapeOptions);
      delegatingTemplateLoaders.add(compiler);
      templateLoader = compiler;
    } else {
      InterpretedTemplateLoader interpreter =
          new InterpretedTemplateLoader(templateFactory, globalFunctions, autoEscapeOptions);
      delegatingTemplateLoaders.add(interpreter);
      templateLoader = interpreter;
    }

    if (options.getPrecompiledTemplateMap() != null) {
      PrecompiledTemplateLoader ptl =
          new PrecompiledTemplateLoader(templateLoader, options.getPrecompiledTemplateMap(),
              globalFunctions, autoEscapeOptions);
      delegatingTemplateLoaders.add(ptl);
      templateLoader = ptl;
    }

    for (DelegatingTemplateLoader loader : delegatingTemplateLoaders) {
      loader.setTemplateLoaderDelegate(templateLoader);
    }
    this.templateLoader = templateLoader;
  } 


Advertisement
Javadoc
TemplateLoader that stores objects from precompiled Template classes and serves them when asked for

them. If not found, it passes the request on to the delegate TemplateLoader.

Read More
Advertisement