Package org.rythmengine.extension

Examples of org.rythmengine.extension.ICodeType


            escape_.set(e);
        }
        public static Escape getEscape() {
            Escape e = escape_.get();
            if (null == e) {
                ICodeType type = getCodeType();
                e = null == type ? Escape.XML : type.escape();
            }
            return e;
        }
View Full Code Here


        }
        this.engine = null == engine ? Rythm.engine() : engine;
        this.conf = this.engine.conf();
        this.requiredDialect = requiredDialect;
        this.templateClass = templateClass;
        ICodeType type = templateClass.codeType;
        this.templateDefLang = type;
        String tmpl = RythmEvents.ON_PARSE.trigger(this.engine, this);
        this.tmpl = tmpl;
        this.parser = new TemplateParser(this);
    }
View Full Code Here

                return codeTypeStack.peek();
            }
        }

        public void pushCodeType(ICodeType type) {
            ICodeType cur = currentCodeType();
            if (null != cur) {
                type.setParent(cur);
            }
            codeTypeStack.push(type);
            Rythm.RenderTime.setCodeType(type);
View Full Code Here

            codeTypeStack.push(type);
            Rythm.RenderTime.setCodeType(type);
        }

        public ICodeType popCodeType() {
            ICodeType cur = codeTypeStack.pop();
            cur.setParent(null);
            return cur;
        }
View Full Code Here

                ".xml",
                ".txt",
                ".rythm",
                ""
        }));
        ICodeType codeType = TemplateResourceBase.getTypeOfPath(engine, tmplName);
        if (ICodeType.DefImpl.RAW == codeType) {
            // use caller's code type
            codeType = callerClass.codeType;
        }
        final String tagNameOrigin = tmplName;
        if (processTagName) {
            boolean withRythmSuffix = S.notEmpty(rythmSuffix);
            for (String s : suffixes) {
                if (tmplName.endsWith(s)) {
                    tmplName = tmplName.substring(0, tmplName.lastIndexOf(s));
                    break;
                }
                if (withRythmSuffix) {
                    s = s + rythmSuffix;
                    if (tmplName.endsWith(s)) {
                        tmplName = tmplName.substring(0, tmplName.lastIndexOf(s));
                        break;
                    }
                }
            }
        }
        tmplName = tmplName.replace('.', '/');
        String sfx = codeType.resourceNameSuffix();
        if (S.notEmpty(sfx) && !suffixes.get(0).equals(sfx)) {
            suffixes.remove(sfx);
            suffixes.add(0, sfx);
        }
View Full Code Here

        String suffix = engine.conf().resourceNameSuffix();
        if (s.endsWith(suffix)) {
            int pos = s.lastIndexOf(suffix);
            if (pos > -1) s = s.substring(0, pos);
        }
        ICodeType codeType = engine.conf().defaultCodeType();
        if (s.endsWith(".html") || s.endsWith(".htm")) {
            codeType = ICodeType.DefImpl.HTML;
        } else if (s.endsWith(".js")) {
            codeType = ICodeType.DefImpl.JS;
        } else if (s.endsWith(".json")) {   
View Full Code Here

        IContext ctx = ctx();
        if (ctx.insideDirectiveComment()) {
            return null;
            //raiseParseException("directive comment not closed");
        }
        ICodeType type = ctx.peekCodeType();
        while (null != type) {
            String sCommentStart = type.commentStart();
            if (!S.empty(sCommentStart)) {
                sCommentStart = S.escapeRegex(sCommentStart).toString();
                // try <!-- @ first
                String s = "(" + sCommentStart + "\\s*" + ")" + ctx.getDialect().a() + ".*";
                Pattern p = patterns.get(s);
                if (null == p) {
                    p = Pattern.compile(s, Pattern.DOTALL);
                    patterns.put(s, p);
                }
                Matcher m = p.matcher(remain());
                if (m.matches()) {
                    s = m.group(1);
                    ctx.step(s.length());
                    ctx.enterDirectiveComment();
                    return Token.EMPTY_TOKEN;
                }
                // try <!-- }
                s = "(" + sCommentStart + "\\s*)\\}.*";
                p = patterns.get(s);
                if (null == p) {
                    p = Pattern.compile(s, Pattern.DOTALL);
                    patterns.put(s, p);
                }
                m = p.matcher(remain());
                if (m.matches()) {
                    s = m.group(1);
                    ctx.step(s.length());
                    ctx.enterDirectiveComment();
                    return Token.EMPTY_TOKEN;
                }
            }
            type = type.getParent();
        }

        return null;
    }
View Full Code Here

    private static Map<String, Pattern> patterns = new HashMap<String, Pattern>();

    @Override
    public Token go() {
        IContext ctx = ctx();
        ICodeType curType = ctx.peekCodeType();
        if (curType.allowedExternalTypes().isEmpty()) return null;

        String remain = ctx.getRemain();

        String blockEnd = curType.blockEnd();
        if (null == blockEnd) {
            logger.warn("null block end found for type[%s]", curType);
            return null;
        }
View Full Code Here

        return codeTypeStack.peek();
    }

    @Override
    public void pushCodeType(ICodeType type) {
        ICodeType cur = peekCodeType();
        if (null != cur) {
            type.setParent(cur);
        }
        codeTypeStack.push(type);
    }
View Full Code Here

        codeTypeStack.push(type);
    }

    @Override
    public ICodeType popCodeType() {
        ICodeType cur = peekCodeType();
        if (null == cur) {
            return null;
        }
        cur.setParent(null);
        codeTypeStack.pop();
        return cur;
    }
View Full Code Here

TOP

Related Classes of org.rythmengine.extension.ICodeType

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.