/** * Parses the template reading from the provided template file and generates an instance of the TagNode * class that gets passed in. The html elements defined in the template file becomes inner elements * of the created TagNode. It then returns the TagNode object that gets created. * * @param tagTemplate Template file * @param cl The TagNode implementation class. * @return Returns the newly created tag node object which contains the template contents. * @throws TemplateLoadingException Might be thrown if there is a problem in parsing the provided template. */ public <T extends TagNode> T createTag(File tagTemplate, Class<T> cl, ExpressionLanguage expressionLanguage) throws TemplateLoadingException { TemplateDocument doc = loader.parseTemplate(tagTemplate, expressionLanguage); ArrayList<TemplateNode> nodes = doc.getChildren(); try { T tag = cl.newInstance(); tag.addChildren(nodes); return tag; } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; } }
/** * Parses the template reading from the provided input stream and generates an instance of the TagNode * class that gets passed in. The html elements defined in the template file becomes inner elements * of the created TagNode. It then returns the TagNode object that gets created. * * @param in InputStream to read the template from. * @param cl The TagNode implementation class. * @return Returns the newly created tag node object which contains the template contents. * @throws TemplateLoadingException Might be thrown if there is a problem in parsing the provided template. */ public <T extends TagNode> T createTag(InputStream in, Class<T> cl, ExpressionLanguage expressionLanguage) throws TemplateLoadingException { TemplateDocument doc = loader.parseTemplate(in, expressionLanguage); ArrayList<TemplateNode> nodes = doc.getChildren(); try { T tag = cl.newInstance(); tag.addChildren(nodes); return tag; } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; }
ArrayList<TemplateNode> children = doc.getChildren(); for (TemplateNode node : children) if (extended == extendedDocument && extendedDocument.getChildren().size() > 0 && extendedDocument.getChildren().get(0) instanceof ExtendsDirective) if (extendedDocument.getChildren().size() > 0 && extendedDocument.getChildren().get(0) instanceof ExtendsDirective) ((ExtendsDirective) extendedDocument.getChildren().get(0)).extend(extendedDocument, f, false);