mirror of
https://github.com/pantor/inja.git
synced 2026-10-18 17:58:14 +00:00
Use callbacks without parameters either with or without parenthesis
This commit is contained in:
1 parent
b68f745866
commit
776af96b0b
3 files changed
+10
-8
No files matched your search
+8
-7
@@ -597,13 +597,14 @@ public:
|
||||
*/
|
||||
static Regex function_regex(std::string name, int number_arguments) {
|
||||
std::string pattern = name;
|
||||
if (number_arguments > 0) {
|
||||
pattern.append("\\(");
|
||||
for (int i = 0; i < number_arguments; i++) {
|
||||
if (i != 0) pattern.append(",");
|
||||
pattern.append("(.*)");
|
||||
}
|
||||
pattern.append("\\)");
|
||||
pattern.append("\\(");
|
||||
for (int i = 0; i < number_arguments; i++) {
|
||||
if (i != 0) pattern.append(",");
|
||||
pattern.append("(.*)");
|
||||
}
|
||||
pattern.append("\\)");
|
||||
if (number_arguments == 0) { // Without arguments, allow to use the callback without parenthesis
|
||||
pattern = "(?:" + name + "|" + pattern + ")";
|
||||
}
|
||||
return Regex{"\\s*" + pattern + "\\s*"};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user