public FreeMarkerTree(Template template) { super(template.getRootTreeNode()); }
@Override public void postProcess(Template t) throws TemplatePostProcessorException { final TemplateElement te = t.getRootTreeNode(); addInterruptionChecks(te); }
private void removeBreakpoints(TemplateDebugInfo tdi) { tdi.breakpoints.clear(); for (Iterator iter = tdi.templates.iterator(); iter.hasNext(); ) { TemplateReference ref = (TemplateReference) iter.next(); Template t = ref.getTemplate(); if (t == null) { iter.remove(); } else { removeDebugBreaks(t.getRootTreeNode()); } } }
public void setTemplate(Template template) { this.setModel(new DefaultTreeModel(template.getRootTreeNode())); this.invalidate(); }
/** * Processes the template to which this environment belongs to. */ public void process() throws TemplateException, IOException { Object savedEnv = threadEnv.get(); threadEnv.set(this); try { // Cached values from a previous execution are possibly outdated. clearCachedValues(); try { doAutoImportsAndIncludes(this); visit(getTemplate().getRootTreeNode()); // It's here as we must not flush if there was an exception. if (getAutoFlush()) { out.flush(); } } finally { // It's just to allow the GC to free memory... clearCachedValues(); } } finally { threadEnv.set(savedEnv); } }
private static void insertDebugBreak(Template t, Breakpoint breakpoint) { TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine()); if (te == null) { return; } TemplateElement parent = _CoreAPI.getParentElement(te); DebugBreak db = new DebugBreak(te); // TODO: Ensure there always is a parent by making sure // that the root element in the template is always a MixedContent // Also make sure it doesn't conflict with anyone's code. parent.setChildAt(parent.getIndex(te), db); }
private void removeDebugBreak(Template t, Breakpoint breakpoint) { TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine()); if (te == null) { return; } DebugBreak db = null; while (te != null) { if (te instanceof DebugBreak) { db = (DebugBreak) te; break; } te = _CoreAPI.getParentElement(te); } if (db == null) { return; } TemplateElement parent = _CoreAPI.getParentElement(db); parent.setChildAt(parent.getIndex(db), _CoreAPI.getChildElement(db, 0)); }
/** * Processes a Template in the context of this <code>Environment</code>, including its output in the * <code>Environment</code>'s Writer. * * @param includedTemplate * the template to process. Note that it does <em>not</em> need to be a template returned by * {@link #getTemplateForInclusion(String name, String encoding, boolean parse)}. */ public void include(Template includedTemplate) throws TemplateException, IOException { final Template prevTemplate; final boolean parentReplacementOn = isBeforeIcI2322(); prevTemplate = getTemplate(); if (parentReplacementOn) { setParent(includedTemplate); } else { legacyParent = includedTemplate; } importMacros(includedTemplate); try { visit(includedTemplate.getRootTreeNode()); } finally { if (parentReplacementOn) { setParent(prevTemplate); } else { legacyParent = prevTemplate; } } }
/** * Determines whether exists a variable specified by the given expression * in the specified template. * * @param template the specified template * @param expression the given expression, for example, * "${aVariable}", "<#list recentComments as comment>" * @return {@code true} if it exists, returns {@code false} otherwise */ public static boolean hasExpression(final Template template, final String expression) { final TemplateElement rootTreeNode = template.getRootTreeNode(); return hasExpression(template, expression, rootTreeNode); }
public FreeMarkerTree(Template template) { super(template.getRootTreeNode()); }
@Override public void postProcess(Template t) throws TemplatePostProcessorException { final TemplateElement te = t.getRootTreeNode(); addInterruptionChecks(te); }
@Override public void postProcess(Template t) throws TemplatePostProcessorException { final TemplateElement te = t.getRootTreeNode(); addInterruptionChecks(te); }
/** * Determines whether exists a variable specified by the given expression * in the specified template. * * @param template the specified template * @param expression the given expression, for example, * "${aVariable}", "<#list recentComments as comment>" * @return {@code true} if it exists, returns {@code false} otherwise */ public static boolean hasExpression(final Template template, final String expression) { final TemplateElement rootTreeNode = template.getRootTreeNode(); return hasExpression(template, expression, rootTreeNode); }
private void removeBreakpoints(TemplateDebugInfo tdi) { tdi.breakpoints.clear(); for (Iterator iter = tdi.templates.iterator(); iter.hasNext(); ) { TemplateReference ref = (TemplateReference) iter.next(); Template t = ref.getTemplate(); if (t == null) { iter.remove(); } else { removeDebugBreaks(t.getRootTreeNode()); } } }
private void removeBreakpoints(TemplateDebugInfo tdi) { tdi.breakpoints.clear(); for (Iterator iter = tdi.templates.iterator(); iter.hasNext(); ) { TemplateReference ref = (TemplateReference) iter.next(); Template t = ref.getTemplate(); if (t == null) { iter.remove(); } else { removeDebugBreaks(t.getRootTreeNode()); } } }
public void setTemplate(Template template) { this.setModel(new DefaultTreeModel(template.getRootTreeNode())); this.invalidate(); }
public void setTemplate(Template template) { this.setModel(new DefaultTreeModel(getNode(template.getRootTreeNode()))); this.invalidate(); }
@SuppressWarnings("unchecked") public static Map<String, String> extractMetaData(Template template) { Enumeration children = template.getRootTreeNode().children(); for (TemplateElement child : new EnumerationIterator<TemplateElement>(children)) { if (child instanceof Comment) { Comment c = (Comment) child; return extractTags(c.getText()); } } return null; }
private static void insertDebugBreak(Template t, Breakpoint breakpoint) { TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine()); if (te == null) { return; } TemplateElement parent = _CoreAPI.getParentElement(te); DebugBreak db = new DebugBreak(te); // TODO: Ensure there always is a parent by making sure // that the root element in the template is always a MixedContent // Also make sure it doesn't conflict with anyone's code. parent.setChildAt(parent.getIndex(te), db); }
private static void insertDebugBreak(Template t, Breakpoint breakpoint) { TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine()); if (te == null) { return; } TemplateElement parent = _CoreAPI.getParentElement(te); DebugBreak db = new DebugBreak(te); // TODO: Ensure there always is a parent by making sure // that the root element in the template is always a MixedContent // Also make sure it doesn't conflict with anyone's code. parent.setChildAt(parent.getIndex(te), db); }