Paste #47887: Untitled Paste

Date: 2018/06/15 00:52:08 UTC-07:00
Type: Server Log

View Raw Paste Download This Paste
Copy Link


        // <--[tag]
        // @attribute <el@element.repeat[<#>]>
        // @returns Element
        // @group element manipulation
        // @description
        // Returns the element repeated.
        // For example: ab .repeat[3] returns ababab.
        // -->
        registerTag("repeat", new TagRunnable() {
            @Override
            public String run(Attribute attribute, dObject object) {
                if (!attribute.hasContext(1)) {
                    dB.echoError("The tag el@element.repeat[...] must have a value.");
                    return null;
                }
                int qty = attribute.getIntContext(1);
                String input = ((Element) object).element;
                String result = input;
                for(int i = 1; i < qty; i++) {
                    result = result + input;
                }
                return new Element(result).getAttribute(attribute.fulfill(1));
            }
        });