Skip to content

Commit

Permalink
[core-utils] modify gnc:format to accept -
Browse files Browse the repository at this point in the history
this allows use of varnames such as ${report-title}
  • Loading branch information
christopherlam committed Jan 16, 2023
1 parent ccc8b44 commit 645cc94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bindings/guile/core-utils.scm
Expand Up @@ -111,7 +111,7 @@
(set-exception-printer! 'unbound-variable print-unbound-variable-error)

;; format.
(define %regex (make-regexp "[$][{]([[:alnum:]]+)[}]"))
(define %regex (make-regexp "[$][{]([[:alnum:]\\-]+)[}]"))
(define (gnc:format str . bindings)
(define hash (make-hash-table))
(define (substitute m)
Expand Down
4 changes: 4 additions & 0 deletions bindings/guile/test/test-core-utils.scm
Expand Up @@ -30,6 +30,10 @@
"basic test"
(gnc:format "basic ${job}" 'job "test"))

(test-equal "one substitution with hyphen"
"master chief"
(gnc:format "master ${job-title}" 'job-title "chief"))

(test-equal "two substitutions out of order"
"basic test"
(gnc:format "${difficulty} ${job}" 'job "test" 'difficulty "basic"))
Expand Down

0 comments on commit 645cc94

Please sign in to comment.