@Override public void compile(ProcessPhase phase, ASTNode.Tag tag, TemplateModel t) throws TemplateException { String path = tag.getArgs().get("path"); Path.Absolute template = phase.resolveTemplate(Path.parse(path)); tag.getArgs().put("path", template.getCanonical()); }
@Override public void compile(ProcessPhase phase, ASTNode.Tag tag, TemplateModel t) throws TemplateException { String path = tag.getArgs().get("path"); Path.Absolute template = phase.resolveTemplate(Path.parse(path)); tag.getArgs().put("path", template.getCanonical()); }
@Override public void compile(ProcessPhase phase, ASTNode.Tag tag, TemplateModel t) throws TemplateException { String path = tag.getArgs().get("path"); Path.Absolute resolved = phase.resolveTemplate(Path.parse(path)); if (resolved == null) { throw TemplateMetaModel.TEMPLATE_NOT_RESOLVED.failure(path); } else { tag.getArgs().put("path", resolved.getCanonical()); } }
throw TemplateMetaModel.CONTROLLER_NOT_RESOLVED.failure( controller, templateModel.getPath().getCanonical(), location.getLine(), location.getCol());
throw TemplateMetaModel.CONTROLLER_NOT_RESOLVED.failure( controller, templateModel.getPath().getCanonical(), location.getLine(), location.getCol());
public TemplatesDescriptor( ApplicationDescriptor application, ClassLoader loader, JSON config) throws Exception { ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>(); List<TemplateDescriptor> templates = new ArrayList<TemplateDescriptor>(); // String packageName = config.getString("package"); Name pkg = Name.parse(packageName); // Load templates for (String fqn : config.getList("templates", String.class)) { Class<?> clazz = loader.loadClass(fqn); Field f = clazz.getField("DESCRIPTOR"); TemplateDescriptor descriptor = (TemplateDescriptor)f.get(null); templates.add(descriptor); juzu.impl.common.Path.Absolute path = (juzu.impl.common.Path.Absolute)juzu.impl.common.Path.parse(descriptor.getPath()); Path qualifier; if (pkg.isPrefix(path.getName())) { juzu.impl.common.Path.Relative relativePath = juzu.impl.common.Path.relative(path.getName().subName(pkg.size()), path.getExt()); qualifier = new PathLiteral(relativePath.getCanonical()); } else { qualifier = new PathLiteral(path.getCanonical()); } beans.add(BeanDescriptor.createFromImpl(Template.class, null, Arrays.<Annotation>asList(qualifier), descriptor.getType())); } // this.templates = templates; this.pkg = pkg; this.beans = beans; }
public TemplatesDescriptor( ApplicationDescriptor application, ClassLoader loader, JSON config) throws Exception { ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>(); List<TemplateDescriptor> templates = new ArrayList<TemplateDescriptor>(); // String packageName = config.getString("package"); Name pkg = Name.parse(packageName); // Load templates for (String fqn : config.getList("templates", String.class)) { Class<?> clazz = loader.loadClass(fqn); Field f = clazz.getField("DESCRIPTOR"); TemplateDescriptor descriptor = (TemplateDescriptor)f.get(null); templates.add(descriptor); juzu.impl.common.Path.Absolute path = (juzu.impl.common.Path.Absolute)juzu.impl.common.Path.parse(descriptor.getPath()); Path qualifier; if (pkg.isPrefix(path.getName())) { juzu.impl.common.Path.Relative relativePath = juzu.impl.common.Path.relative(path.getName().subName(pkg.size()), path.getExt()); qualifier = new PathLiteral(relativePath.getCanonical()); } else { qualifier = new PathLiteral(path.getCanonical()); } beans.add(BeanDescriptor.createFromImpl(Template.class, null, Arrays.<Annotation>asList(qualifier), descriptor.getType())); } // this.templates = templates; this.pkg = pkg; this.beans = beans; }
@Override public Timestamped<Resource> resolveResource(Path.Absolute path) { FileObject resource = owner.application.resolveResource(path); if (resource != null) { try { byte[] bytes = Tools.bytes(resource.openInputStream()); long lastModified = resource.getLastModified(); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); } catch (Exception e) { env.info("Could not get resource content " + path.getCanonical(), e); } } return null; }
@Override public Timestamped<Resource> resolveResource(Path.Absolute path) { FileObject resource = owner.application.resolveResource(path); if (resource != null) { try { byte[] bytes = Tools.bytes(resource.openInputStream()); long lastModified = resource.getLastModified(); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); } catch (Exception e) { env.info("Could not get resource content " + path.getCanonical(), e); } } return null; }
public JSON toJSON() { JSON json = new JSON(); json.set("path", path.getCanonical()); return json; }
public JSON toJSON() { JSON json = new JSON(); json.set("path", path.getCanonical()); return json; }
@Override public void compile(ProcessPhase phase, ASTNode.Tag tag, TemplateModel t) throws TemplateException { String path = tag.getArgs().get("path"); Path.Absolute resolved = phase.resolveTemplate(Path.parse(path)); if (resolved == null) { throw TemplateMetaModel.TEMPLATE_NOT_RESOLVED.failure(path); } else { tag.getArgs().put("path", resolved.getCanonical()); } }