Skip to content

Commit

Permalink
add tag list.parse[tag]
Browse files Browse the repository at this point in the history
A meta tag-tag.
  • Loading branch information
mcmonkey4eva committed Oct 19, 2014
1 parent 343ac36 commit 0b76672
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dList.java
Expand Up @@ -889,6 +889,28 @@ else if (res > 0)
return new dList(list).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <li@list.parse[<tag>]>
// @returns dList
// @description
// returns a copy of the list with all its contents parsed through the given tag.
// For example, a list of 'one|two' .parse[to_uppercase] returns a list of 'ONE|TWO'.
// -->
if (attribute.startsWith("parse")
&& attribute.hasContext(1)) {
dList newlist = new dList();
try {
for (String str: this) {
newlist.add(ObjectFetcher.pickObjectFor(str).getAttribute(new Attribute(attribute.getContext(1),
attribute.getScriptEntry())));
}
}
catch (Exception ex) {
dB.echoError(ex);
}
return newlist.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <li@list.escape_contents>
// @returns dList
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/aufdemrand/denizen/tags/TagManager.java
Expand Up @@ -23,7 +23,7 @@

public class TagManager implements Listener {

private static class TagContext {
public static class TagContext {
public final dPlayer player;
public final dNPC npc;
public final boolean instant;
Expand Down

0 comments on commit 0b76672

Please sign in to comment.