Updated join so join() works correctly, #706
This commit is contained in:
@@ -51,7 +51,7 @@ Valid filters are:
|
||||
- `rsort`: Sort list of values in reverse order, e.g. ['a', 'b', 'c'] => ['c', 'b', 'a'].
|
||||
- `reverse`: Reverse order of values, e.g. ['a', 'b', 'c'] => ['c', 'b', 'a'].
|
||||
- `uniq`: Remove duplicate values, e.g. ['a', 'b', 'c', 'b', 'a'] => ['a', 'b', 'c'].
|
||||
- `join(x)`: Join list of values with delimiter x, e.g. join(:): ['a', 'b', 'c'] => 'a:b:c'; the DELIM option functions similar to join(x) but with DELIM, the join happens before being passed to any filters.
|
||||
- `join(x)`: Join list of values with delimiter x, e.g. join(:): ['a', 'b', 'c'] => 'a:b:c'; the DELIM option functions similar to join(x) but with DELIM, the join happens before being passed to any filters.May optionally be used without an argument, that is 'join()' which joins values together with no delimiter. e.g. join(): ['a', 'b', 'c'] => 'abc'.
|
||||
- `append(x)`: Append x to list of values, e.g. append(d): ['a', 'b', 'c'] => ['a', 'b', 'c', 'd'].
|
||||
- `prepend(x)`: Prepend x to list of values, e.g. prepend(d): ['a', 'b', 'c'] => ['d', 'a', 'b', 'c'].
|
||||
- `remove(x)`: Remove x from list of values, e.g. remove(b): ['a', 'b', 'c'] => ['a', 'c'].
|
||||
|
||||
@@ -253,7 +253,10 @@ FILTER_VALUES = {
|
||||
"rsort": "Sort list of values in reverse order, e.g. ['a', 'b', 'c'] => ['c', 'b', 'a'].",
|
||||
"reverse": "Reverse order of values, e.g. ['a', 'b', 'c'] => ['c', 'b', 'a'].",
|
||||
"uniq": "Remove duplicate values, e.g. ['a', 'b', 'c', 'b', 'a'] => ['a', 'b', 'c'].",
|
||||
"join(x)": "Join list of values with delimiter x, e.g. join(:): ['a', 'b', 'c'] => 'a:b:c'; the DELIM option functions similar to join(x) but with DELIM, the join happens before being passed to any filters.",
|
||||
"join(x)": "Join list of values with delimiter x, e.g. join(:): ['a', 'b', 'c'] => 'a:b:c'; "
|
||||
+ "the DELIM option functions similar to join(x) but with DELIM, the join happens before being passed to any filters."
|
||||
+ "May optionally be used without an argument, that is 'join()' which joins values together with no delimiter. "
|
||||
+ "e.g. join(): ['a', 'b', 'c'] => 'abc'.",
|
||||
"append(x)": "Append x to list of values, e.g. append(d): ['a', 'b', 'c'] => ['a', 'b', 'c', 'd'].",
|
||||
"prepend(x)": "Prepend x to list of values, e.g. prepend(d): ['a', 'b', 'c'] => ['d', 'a', 'b', 'c'].",
|
||||
"remove(x)": "Remove x from list of values, e.g. remove(b): ['a', 'b', 'c'] => ['a', 'c'].",
|
||||
@@ -1160,7 +1163,6 @@ class PhotoTemplate:
|
||||
"split",
|
||||
"chop",
|
||||
"chomp",
|
||||
"join",
|
||||
"append",
|
||||
"prepend",
|
||||
"remove",
|
||||
@@ -1234,7 +1236,7 @@ class PhotoTemplate:
|
||||
value = temp_values
|
||||
elif filter_ == "join":
|
||||
# join list of values with delimiter
|
||||
delim = args
|
||||
delim = args or ""
|
||||
value = [delim.join(values)]
|
||||
elif filter_ == "append":
|
||||
# append value to list
|
||||
|
||||
@@ -215,6 +215,7 @@ TEMPLATE_VALUES = {
|
||||
"{descr|brackets}": "[Jack Rose Dining Saloon]",
|
||||
"{descr|split( )|join(|)}": "Jack|Rose|Dining|Saloon",
|
||||
"{descr|autosplit|join(|)}": "Jack|Rose|Dining|Saloon",
|
||||
"{descr|autosplit|join()}": "JackRoseDiningSaloon",
|
||||
"{descr|autosplit|chop(1)|join(|)}": "Jac|Ros|Dinin|Saloo",
|
||||
"{descr|autosplit|chomp(1)|join(|)}": "ack|ose|ining|aloon",
|
||||
"{descr|chop(2)}": "Jack Rose Dining Salo",
|
||||
|
||||
Reference in New Issue
Block a user