Package freemarker.core.ast

Examples of freemarker.core.ast.TemplateElement


    static public Template getPlainTextTemplate(String name, String content,
            Configuration config) {
         Template template = new Template(name, config, NULL_CODE_SOURCE);
        final char[] text = content.toCharArray();
        template.templateText = text;
        template.setRootElement(new TemplateElement() {
          public void execute(Environment env) throws IOException {
            env.getOut().write(text);
          }
        });
        DebuggerService.registerTemplate(template);
View Full Code Here


     * permission.
     */
    public List<TemplateElement> containingElements(int column, int line) {
        checkModifyTemplate();
        ArrayList<TemplateElement> elements = new ArrayList<TemplateElement>();
        TemplateElement element = getRootElement();
mainloop:
        while (element.contains(column, line)) {
            elements.add(element);
            for (Enumeration enumeration = element.children(); enumeration.hasMoreElements();) {
                TemplateElement elem = (TemplateElement) enumeration.nextElement();
                if (elem.contains(column, line)) {
                    element = elem;
                    continue mainloop;
                }
            }
            break;
View Full Code Here

        }
    }

    private static void insertDebugBreak(Template t, Breakpoint breakpoint)
    {
        TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine());
        if(te == null)
        {
            return;
        }
        TemplateElement parent = te.getParent();
        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);
    }
View Full Code Here

            return null;
        }
        // Find the narrowest match
        for(Enumeration children = te.children(); children.hasMoreElements();)
        {
            TemplateElement child = (TemplateElement)children.nextElement();
            TemplateElement childmatch = findTemplateElement(child, line);
            if(childmatch != null)
            {
                return childmatch;
            }
        }
View Full Code Here

        }
    }

    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 = te.getParent();
        }
        if(db == null)
        {
            return;
        }
        TemplateElement parent = db.getParent();
        parent.setChildAt(parent.getIndex(db), db.getChildAt(0));
    }
View Full Code Here

    private void removeDebugBreaks(TemplateElement te)
    {
        int count = te.getChildCount();
        for(int i = 0; i < count; ++i)
        {
            TemplateElement child = te.getChildAt(i);
            while(child instanceof DebugBreak)
            {
                TemplateElement dbchild = child.getChildAt(0);
                te.setChildAt(i, dbchild);
                child = dbchild;
            }
            removeDebugBreaks(child);
        }
View Full Code Here

TOP

Related Classes of freemarker.core.ast.TemplateElement

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.