Example usage for org.apache.commons.jelly.impl TagScript addAttribute

List of usage examples for org.apache.commons.jelly.impl TagScript addAttribute

Introduction

In this page you can find the example usage for org.apache.commons.jelly.impl TagScript addAttribute.

Prototype

public void addAttribute(String name, Expression expression) 

Source Link

Document

Add an initialization attribute for the tag.

Usage

From source file:org.kohsuke.stapler.jelly.groovy.JellyBuilder.java

/**
 * Create a tag script if the given QName is a taglib invocation, or return null
 * to handle it like a literal static tag.
 *//*from  w w  w  . ja  v a  2s  .  com*/
private TagScript createTagScript(QName n, Map<?, ?> attributes) throws JellyException {
    TagLibrary lib = context.getTagLibrary(n.getNamespaceURI());
    if (lib != null) {
        String localName = n.getLocalPart();

        TagScript tagScript = lib.createTagScript(localName, null/*this parameter appears to be unused.*/);
        if (tagScript == null)
            tagScript = lib.createTagScript(localName.replace('_', '-'), null);

        if (tagScript != null) {
            if (attributes != null) {
                for (Entry e : attributes.entrySet()) {
                    Object v = e.getValue();
                    if (v != null)
                        tagScript.addAttribute(e.getKey().toString(), new ConstantExpression(v));
                }
            }

            return tagScript;
        }
    }

    // otherwise treat it as a literal.
    return null;
}