Add substitute function
This commit is contained in:
parent
877efd7f95
commit
01fc086e62
@ -19,6 +19,7 @@
|
||||
has-duplicates? find-duplicates
|
||||
insert-between
|
||||
string-replace-text
|
||||
substitute
|
||||
read-template
|
||||
|
||||
make-mux-selectors))
|
||||
@ -194,6 +195,15 @@
|
||||
str))
|
||||
str))))))
|
||||
|
||||
;;; Substitute template
|
||||
(define (substitute text template-format subst-list)
|
||||
(fold (lambda (s out)
|
||||
(string-replace-text
|
||||
out
|
||||
(format template-format (first s))
|
||||
(format "~a" (second s))))
|
||||
text subst-list))
|
||||
|
||||
;;; Read template and substitute replacements
|
||||
;;; Returns list of strings (lines)
|
||||
(define (read-template template-file template-format subst-list)
|
||||
@ -204,10 +214,6 @@
|
||||
(if (eof-object? s)
|
||||
(reverse l)
|
||||
(loop (cons s l)))))))))
|
||||
(map (lambda (str) (fold (lambda (s out)
|
||||
(string-replace-text
|
||||
out
|
||||
(format template-format (first s))
|
||||
(format "~a" (second s))))
|
||||
str subst-list))
|
||||
(map (lambda (str)
|
||||
(substitute str template-format subst-list))
|
||||
ls)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user