Search in sources :

Example 1 with CustomTagLib

use of lucee.transformer.library.tag.CustomTagLib in project Lucee by lucee.

the class CFMLTransformer method executeEvaluator.

private boolean executeEvaluator(TagData data, TagLibTag tagLibTag, Tag tag) throws TemplateException {
    if (tagLibTag.hasTTE()) {
        try {
            TagLib lib = tagLibTag.getEvaluator().execute(data.config, tag, tagLibTag, data.flibs, data);
            if (lib != null) {
                // set
                for (int i = 0; i < data.tlibs[TAG_LIB_PAGE].length; i++) {
                    if (data.tlibs[TAG_LIB_PAGE][i].getNameSpaceAndSeparator().equalsIgnoreCase(lib.getNameSpaceAndSeparator())) {
                        boolean extIsCustom = data.tlibs[TAG_LIB_PAGE][i] instanceof CustomTagLib;
                        boolean newIsCustom = lib instanceof CustomTagLib;
                        // TagLib + CustomTagLib (visa/versa)
                        if (extIsCustom) {
                            ((CustomTagLib) data.tlibs[TAG_LIB_PAGE][i]).append(lib);
                            return true;
                        } else if (newIsCustom) {
                            ((CustomTagLib) lib).append(data.tlibs[TAG_LIB_PAGE][i]);
                            data.tlibs[TAG_LIB_PAGE][i] = lib;
                            return true;
                        }
                    }
                }
                // TODO make sure longer namespace ar checked firts to support subsets, same for core libs
                // insert
                TagLib[] newTlibs = new TagLib[data.tlibs[TAG_LIB_PAGE].length + 1];
                for (int i = 0; i < data.tlibs[TAG_LIB_PAGE].length; i++) {
                    newTlibs[i] = data.tlibs[TAG_LIB_PAGE][i];
                }
                newTlibs[data.tlibs[TAG_LIB_PAGE].length] = lib;
                data.tlibs[TAG_LIB_PAGE] = newTlibs;
            }
        } catch (EvaluatorException e) {
            throw new TemplateException(data.srcCode, e);
        }
    }
    return true;
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) AttributeEvaluatorException(lucee.transformer.cfml.attributes.AttributeEvaluatorException) ComponentTemplateException(lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException) TemplateException(lucee.runtime.exp.TemplateException) TagLib(lucee.transformer.library.tag.TagLib) CustomTagLib(lucee.transformer.library.tag.CustomTagLib) CustomTagLib(lucee.transformer.library.tag.CustomTagLib)

Aggregations

TemplateException (lucee.runtime.exp.TemplateException)1 AttributeEvaluatorException (lucee.transformer.cfml.attributes.AttributeEvaluatorException)1 EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)1 ComponentTemplateException (lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException)1 CustomTagLib (lucee.transformer.library.tag.CustomTagLib)1 TagLib (lucee.transformer.library.tag.TagLib)1