Search in sources :

Example 1 with TagOutput

use of lucee.transformer.bytecode.statement.tag.TagOutput in project Lucee by lucee.

the class Output method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag, FunctionLib[] flibs) throws EvaluatorException {
    TagOutput output = (TagOutput) tag;
    // check if inside a query tag
    TagOutput parent = output;
    // encodeFor
    Attribute encodeFor = tag.getAttribute("encodefor");
    if (encodeFor != null) {
        Expression encodeForValue = CastString.toExprString(encodeFor.getValue());
        if (encodeForValue instanceof Literal) {
            Literal l = (Literal) encodeForValue;
            short df = (short) -1;
            short encType = ESAPIEncode.toEncodeType(l.getString(), df);
            if (encType != df)
                encodeForValue = encodeForValue.getFactory().createLitInteger(encType);
        }
        addEncodeToChildren(tag.getBody().getStatements().iterator(), encodeForValue, getEncodeForFunction(flibs));
    }
    // query
    boolean hasParentWithGroup = false;
    boolean hasParentWithQuery = false;
    boolean hasQuery = tag.containsAttribute("query");
    while ((parent = getParentTagOutput(parent)) != null) {
        if (!hasParentWithQuery)
            hasParentWithQuery = parent.hasQuery();
        if (!hasParentWithGroup)
            hasParentWithGroup = parent.hasGroup();
        if (hasParentWithQuery && hasParentWithGroup)
            break;
    }
    if (hasQuery && hasParentWithQuery)
        throw new EvaluatorException("Nesting of tags cfoutput with attribute query is not allowed");
    if (hasQuery)
        output.setType(TagOutput.TYPE_QUERY);
    else if (tag.containsAttribute("group") && hasParentWithQuery)
        output.setType(TagOutput.TYPE_GROUP);
    else if (hasParentWithQuery) {
        if (hasParentWithGroup)
            output.setType(TagOutput.TYPE_INNER_GROUP);
        else
            output.setType(TagOutput.TYPE_INNER_QUERY);
    } else
        output.setType(TagOutput.TYPE_NORMAL);
    // attribute maxrows and endrow not allowd at the same time
    if (tag.containsAttribute("maxrows") && tag.containsAttribute("endrow"))
        throw new EvaluatorException("Wrong Context, you cannot use attribute maxrows and endrow at the same time.");
}
Also used : TagOutput(lucee.transformer.bytecode.statement.tag.TagOutput) Attribute(lucee.transformer.bytecode.statement.tag.Attribute) Expression(lucee.transformer.expression.Expression) EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) Literal(lucee.transformer.expression.literal.Literal)

Example 2 with TagOutput

use of lucee.transformer.bytecode.statement.tag.TagOutput in project Lucee by lucee.

the class Mail method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    if (tag.containsAttribute("query")) {
        TagLib lib = libTag.getTagLib();
        TagLibTag outputTag = lib.getTag("output");
        TagOutput output = new TagOutput(tag.getFactory(), tag.getStart(), null);
        output.setFullname(outputTag.getFullName());
        output.setTagLibTag(outputTag);
        output.addAttribute(new Attribute(false, "output", tag.getFactory().TRUE(), "boolean"));
        output.addAttribute(new Attribute(false, "formail", tag.getFactory().TRUE(), "boolean"));
        // output.getBody();
        Body body = new BodyBase(tag.getFactory());
        output.setBody(body);
        ASMUtil.replace(tag, output, false);
        body.addStatement(tag);
        output.addAttribute(tag.removeAttribute("query"));
        if (tag.containsAttribute("group"))
            output.addAttribute(tag.removeAttribute("group"));
        if (tag.containsAttribute("groupcasesensitive"))
            output.addAttribute(tag.removeAttribute("groupcasesensitive"));
        if (tag.containsAttribute("startrow"))
            output.addAttribute(tag.removeAttribute("startrow"));
        if (tag.containsAttribute("maxrows"))
            output.addAttribute(tag.removeAttribute("maxrows"));
        new Output().evaluate(output, outputTag);
    }
}
Also used : TagLibTag(lucee.transformer.library.tag.TagLibTag) TagOutput(lucee.transformer.bytecode.statement.tag.TagOutput) Attribute(lucee.transformer.bytecode.statement.tag.Attribute) TagLib(lucee.transformer.library.tag.TagLib) TagOutput(lucee.transformer.bytecode.statement.tag.TagOutput) Body(lucee.transformer.bytecode.Body) BodyBase(lucee.transformer.bytecode.BodyBase)

Aggregations

Attribute (lucee.transformer.bytecode.statement.tag.Attribute)2 TagOutput (lucee.transformer.bytecode.statement.tag.TagOutput)2 Body (lucee.transformer.bytecode.Body)1 BodyBase (lucee.transformer.bytecode.BodyBase)1 EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)1 Expression (lucee.transformer.expression.Expression)1 Literal (lucee.transformer.expression.literal.Literal)1 TagLib (lucee.transformer.library.tag.TagLib)1 TagLibTag (lucee.transformer.library.tag.TagLibTag)1