Opened 12 years ago
Last modified 8 years ago
#11119 new enhancement
Strip whitespace from macro arguments
Reported by: | Ryan J Ollos | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | AccountManagerPlugin |
Severity: | normal | Keywords: | macro argument |
Cc: | osimons, Jun Omae | Trac Release: | 0.11 |
Description (last modified by )
While working on a patch t:#10751, I added a stripws
argument to parse_args
, to strip leading and trailing whitespace from macro arguments (see cd5f4cee). There hasn't been any interest expressed in the patch so far, but I encountered a situation this evening that made me think we should deal with this directly in the UserStats
macro.
The macro call [[UserQuery(email, name, visit)]]
results in the list [u'email', u' name', u' visit']
. The output of the macro is then,
admin, user1 <user1@gmail.com>, user2 <user2@gmail.com>
rather than the expected,
Account | Name | Last Login | |
---|---|---|---|
admin | |||
user1 | User One | user1@gmail.com | 16 hours ago |
user2 | User Two | user2@gmail.com |
Attachments (0)
Change History (5)
comment:1 Changed 12 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 12 years ago by
comment:3 follow-up: 4 Changed 12 years ago by
Cc: | osimons Jun Omae added; anonymous removed |
---|---|
Keywords: | macro argument added |
Trac Release: | → 0.11 |
Sure, but I really wonder, why parse_args
does not behave like that in the first place.
Something like parse_args(content, strip=true)
comes in mind, if it should not be desired as default for whatever reason. I just can't think of a valid one right now, anyone else?
comment:4 Changed 12 years ago by
Replying to hasienda:
Sure, but I really wonder, why
parse_args
does not behave like that in the first place.
Same thoughts here. In the patch for Trac, I set the default to stripws=False
for backward compatibility, but backward-compatibility considerations aside, I think stripws=True
is a better default.
Most of the macros in Trac end up stripping whitespace after parse_args
is called, for example TracIni macro.
comment:5 Changed 8 years ago by
Owner: | Steffen Hoffmann deleted |
---|
Here is what I have in mind: Implement a
_parse_args
function inacctmgr.macros
that callstrac.wiki.api.parse_args
and strips whitespace from the parameters. That way it will be easy to write a test case and the function can be reused if we end up with multiple classes inacct_mgr.macros
later on.