Package juzu.impl.template.spi.juzu.compiler

Examples of juzu.impl.template.spi.juzu.compiler.ProcessPhase


    }
  }

  @Override
  public final void process(ProcessContext context, TemplateModel<ASTNode.Template> templateModel) throws TemplateException {
    new ProcessPhase(context).process(templateModel);
  }
View Full Code Here


    Name fqn = pkg.append(name);
    Path.Absolute absolute = Path.absolute(fqn, ".gtmpl");
    Path.Relative relative = Path.relative(name, ".gtmpl");
    GroovyTemplateEmitter generator = new GroovyTemplateEmitter(fqn);
    try {
      ProcessPhase processPhase = new ProcessPhase(new SimpleProcessContext(Collections.<Path.Absolute, TemplateModel<?>>emptyMap()) {
        @Override
        public Path.Absolute resolveTemplate(Path path) throws TemplateException {
          return null;
        }
        @Override
        public TagHandler resolveTagHandler(String name) {
          if ("title".equals(name)) {
            return new TitleTag();
          } else {
            return null;
          }
        }
        @Override
        public MethodInvocation resolveMethodInvocation(String typeName, String methodName, Map<String, String> parameterMap) throws ProcessingException {
          if (parameterMap.size() > 0) {
            throw failure("Unexpected non empty parameter map");
          }
          Class clazz = AbstractTemplateTestCase.this.getClass();
          try {
            Method m = clazz.getMethod(methodName);
            return new MethodInvocation(clazz.getName(), m.getName(), Collections.<String>emptyList());
          }
          catch (NoSuchMethodException e) {
            // Should we thrown a CompilationException instead ?
            throw failure(e);
          }
        }
      });
      TemplateModel<ASTNode.Template> templateModel = new TemplateModel<ASTNode.Template>(
          ASTNode.Template.parse(text),
          absolute,
          0,
          0);
      processPhase.process(templateModel);

      // Emit
      EmitPhase emitPhase = new EmitPhase(new EmitContext(){
        @Override
        public TagHandler resolveTagHandler(String name) {
View Full Code Here

      0);

    //
    HashMap<Path.Absolute, TemplateModel<?>> templates = new HashMap<Path.Absolute, TemplateModel<?>>();
    templates.put((Path.Absolute)Path.parse("/foo.gtmpl"), foo);
    ProcessPhase process = new ProcessPhase(new SimpleProcessContext(templates) {
      @Override
      public Path.Absolute resolveTemplate(Path path) {
        if (path.getCanonical().equals("index.gtmpl")) {
          return (Path.Absolute)Path.parse("/plugin/template/tag/decorate/templates/index.gtmpl");
        }
        else {
          return null;
        }
      }
    });
    Path.Absolute template = process.resolveTemplate(Path.parse("index.gtmpl"));
    assertNotNull(template);

    // Now emit the template
    EmitPhase emit = new EmitPhase(new EmitContext(){
      public TagHandler resolveTagHandler(String name) {
View Full Code Here

TOP

Related Classes of juzu.impl.template.spi.juzu.compiler.ProcessPhase

Copyright © 2018 www.massapicom. 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.