Examples of TemplateCompiler


Examples of com.google.caja.plugin.templates.TemplateCompiler

    TemplateSanitizer ts = new TemplateSanitizer(htmlSchema, mq);
    for (IhtmlRoot ihtmlRoot : html) {
      ts.sanitize(ihtmlRoot.root);
    }

    TemplateCompiler tc = new TemplateCompiler(
        html, css, js, cssSchema, htmlSchema,
        jobs.getPluginMeta(), jobs.getMessageContext(), mq);
    Pair<List<SafeHtmlChunk>, List<SafeJsChunk>> htmlAndJs = tc.getSafeHtml(
        DomParser.makeDocument(null, null));

    for (SafeHtmlChunk outputHtml : htmlAndJs.a) {
      Job outJob = makeJobFromHtml(outputHtml.root, outputHtml.baseUri);
      if (outJob != null) {
View Full Code Here

Examples of com.google.caja.plugin.templates.TemplateCompiler

    TemplateSanitizer ts = new TemplateSanitizer(htmlSchema, mq);
    for (IhtmlRoot ihtmlRoot : html) {
      ts.sanitize(ihtmlRoot.root);
    }

    TemplateCompiler tc = new TemplateCompiler(
        html, css, js, cssSchema, htmlSchema,
        jobs.getPluginMeta(), jobs.getMessageContext(), mq);
    Pair<List<SafeHtmlChunk>, List<SafeJsChunk>> htmlAndJs = tc.getSafeHtml(
        DomParser.makeDocument(null, null));

    for (SafeHtmlChunk outputHtml : htmlAndJs.a) {
      Job outJob = makeJobFromHtml(outputHtml.root, outputHtml.baseUri);
      if (outJob != null) {
View Full Code Here

Examples of com.google.caja.plugin.templates.TemplateCompiler

        + "<div><script>a()</script>Hello <script>b()</script>World!!!</div>\n"
        + "<h1>Foo <b><script>c()</script>Bar</b> Baz</h1>\n"
        + "<h2 id='x'>Boo</h2>\n");
    PluginMeta meta = new PluginMeta();
    List<ScriptPlaceholder> extractedScripts = Lists.newArrayList();
    TemplateCompiler tc = new TemplateCompiler(
        Collections.singletonList(new IhtmlRoot(
            new JobEnvelope(
                null, JobCache.none(), ContentType.HTML, false, null),
            htmlWithScriptsExtracted(input, extractedScripts), is.getUri())),
        Collections.<ValidatedStylesheet>emptyList(), extractedScripts,
        CssSchema.getDefaultCss21Schema(mq), HtmlSchema.getDefault(mq),
        meta, mc, mq);
    Pair<List<SafeHtmlChunk>, List<SafeJsChunk>> htmlAndJs = tc.getSafeHtml(
        DomParser.makeDocument(null, null));

    assertEquals(
        ""
        + "<p>Hi</p>"
View Full Code Here

Examples of com.google.clearsilver.jsilver.compiler.TemplateCompiler

    AutoEscapeOptions autoEscapeOptions = new AutoEscapeOptions();
    autoEscapeOptions.setPropagateEscapeStatus(options.getPropagateEscapeStatus());
    autoEscapeOptions.setLogEscapedVariables(options.getLogEscapedVariables());
    if (options.getCompileTemplates()) {
      // Compiled templates.
      TemplateCompiler compiler =
          new TemplateCompiler(templateFactory, globalFunctions, autoEscapeOptions);
      delegatingTemplateLoaders.add(compiler);
      templateLoader = compiler;
    } else {
      // Walk parse tree every time.
      InterpretedTemplateLoader interpreter =
View Full Code Here

Examples of com.google.sitebricks.compiler.TemplateCompiler

  public Renderable compile(PageBook.Page page) {

      Show methodShow = page.getShow();

      Template template = load(page.pageClass(), methodShow);
      TemplateCompiler templateCompiler = templateSystem.compilerFor(template.getName());

      if (templateCompiler == null) {
        templateCompiler = templateSystem.compilerFor("html");
      }

      return templateCompiler.compile(page.pageClass(), template);
    }
View Full Code Here

Examples of com.google.sitebricks.compiler.TemplateCompiler

      return templateCompiler.compile(page.pageClass(), template);
    }

  public Renderable compile(Class<?> templateClass) {
      Template template = load(templateClass, null);
      TemplateCompiler templateCompiler = templateSystem.compilerFor(template.getName());
      //
      // This is how the old mechanism worked, for example if dynamic.js comes through the system we still pass back
      // the html compiler. JVZ: not sure why this wouldn't be directly routed to the right resource. TODO: investigate
      //
      if (templateCompiler == null) {
        templateCompiler = templateSystem.compilerFor("html");
      }

      return templateCompiler.compile(templateClass, template);
    }
View Full Code Here

Examples of org.ajax4jsf.templatecompiler.builder.TemplateCompiler

//         
//          baseclass = baseclass.getSuperclass();
//            } while (baseclass != null);
//        }
       
        TemplateCompiler templateCompiler = new TemplateCompiler();
        InputStream templateStream = new FileInputStream(template);
        templateCompiler.processing(templateStream, rendererBean);
        renderer.setClassname(rendererBean.getFullClassName());
        String resultPath = rendererBean.getComponentFileName();
        if (null == getPackage()) {
          resultPath = resultPath.replace('.', '/');
        } else {
          resultPath = getPackage().replace('.', '/') + "/"
              + resultPath;
        }

        File javaFile = new File(getDestDir(), resultPath + ".java");
        File javaDir = javaFile.getParentFile();
        if (!javaDir.exists()) {
          javaDir.mkdirs();
        }
        if (javaFile.exists()) {
          if (renderer.isOverride()) {
            javaFile.delete();
          } else {
            return;
          }
        }
        Writer out = new BufferedWriter(new FileWriter(javaFile));
        templateCompiler.generateCode(rendererBean, out);
        out.flush();
        out.close();
      } catch (Exception e) {
        throw new GeneratorException(
            "Error create Renderer Java file ", e);
View Full Code Here

Examples of org.ajax4jsf.templatecompiler.builder.TemplateCompiler

            template = new File(getTemplates(), templateString);
          } else {
            template = new File(templateString);
          }

          TemplateCompiler templateCompiler = new TemplateCompiler();
          InputStream templateStream = new FileInputStream(template);
          templateCompiler.processing(templateStream,
              compilationContext);

          TemplateElement root = compilationContext.getTree();

          String classname = renderer.getClassname();
View Full Code Here

Examples of org.ajax4jsf.templatecompiler.builder.TemplateCompiler

    ClassLoader loader = getClassLoader();

    try {

      CompilationContext componentBean = new AntCompilationContext(this,loader);
      TemplateCompiler templateCompiler = new TemplateCompiler();

      // componentBean.setDefaultVariables();

      InputStream inputStream = null;
      File inputFile = new File(sFileTemplate);
      String sF = inputFile.getName().toString();

      componentBean.setFullClassName(generateJavaClassName(sF));

      inputStream = new FileInputStream(inputFile);

      templateCompiler.processing(inputStream, componentBean);

      String resultPath = componentBean.getComponentFileName() + ".java";
      File javaFile = new File(getDestdir(), resultPath);
      File javaDir = javaFile.getParentFile();
      if (!javaDir.exists()) {
        javaDir.mkdirs();
      } // try

      if (javaFile.exists()) {
        javaFile.delete();
      } // if

      Writer out = new BufferedWriter(new FileWriter(javaFile));
     
      templateCompiler.generateCode(componentBean, out);

      out.flush();
      out.close();
    } catch (FileNotFoundException e) {
      throw new BuildException(e);
View Full Code Here

Examples of org.mvel2.templates.TemplateCompiler

    public void testPluginNode() {
        Map<String, Class<? extends org.mvel2.templates.res.Node>> plugins = new HashMap<String, Class<? extends org.mvel2.templates.res.Node>>();
        plugins.put("testNode", TestPluginNode.class);

        TemplateCompiler compiler = new TemplateCompiler("Foo:@testNode{}!!", plugins);
        CompiledTemplate compiled = compiler.compile();

        assertEquals("Foo:THIS_IS_A_TEST!!", TemplateRuntime.execute(compiled));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.