Skip to content

Commit

Permalink
Add .exclude[item|…] for dLists.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Aug 3, 2013
1 parent 645fcd8 commit 73fc090
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dList.java
Expand Up @@ -253,6 +253,26 @@ public String getAttribute(Attribute attribute) {
.getAttribute(attribute.fulfill(1));
}

// <--
// <li@list.exclude[...|...] -> dList
// returns a new dList excluding the items specified.
// -->
if (attribute.startsWith("exclude")) {
String[] exclusions = attribute.getContext(1).split("\\|");
// Create a new dList that will contain the exclusions
dList list = new dList(this);
// Iterate through
for (String exclusion : exclusions)
for (String value : list)
// If the value of the list equals the value of the exclusion,
// remove it.
if (value.equalsIgnoreCase(exclusion))
list.remove(value);

// Return the modified list
return list.getAttribute(attribute.fulfill(1));
}

// <--
// <li@list.get[#]> -> Element
// returns an Element of the value specified by the supplied context.
Expand Down

0 comments on commit 73fc090

Please sign in to comment.