Example usage for org.apache.commons.jelly TagLibrary createTagScript

List of usage examples for org.apache.commons.jelly TagLibrary createTagScript

Introduction

In this page you can find the example usage for org.apache.commons.jelly TagLibrary createTagScript.

Prototype

public TagScript createTagScript(String name, Attributes attributes) throws JellyException 

Source Link

Document

Creates a new script to execute the given tag name and attributes

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  ww . j a va 2s .  c o m*/
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;
}