about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-08-28 23:20:53 -0500
committerCase Duckworth2023-08-28 23:20:53 -0500
commit8701fe064a6b56e203f6a452d65d18216f18777e (patch)
treef50ab4d60acbd09986114b473c16445c2e30e43f
parentAdd unprintable helper functions (diff)
downloadschmaltz-8701fe064a6b56e203f6a452d65d18216f18777e.tar.gz
schmaltz-8701fe064a6b56e203f6a452d65d18216f18777e.zip
Change render semantics
Now `render` outputs to the current output port, not a string.

`render->string` and `render-string->string` added to output to a string.
-rw-r--r--schmaltz.sld2
-rw-r--r--schmaltz.sls13
2 files changed, 15 insertions, 0 deletions
diff --git a/schmaltz.sld b/schmaltz.sld index 31ed610..e47defb 100644 --- a/schmaltz.sld +++ b/schmaltz.sld
@@ -1,6 +1,8 @@
1(define-library (schmaltz) 1(define-library (schmaltz)
2 (export render 2 (export render
3 render-string 3 render-string
4 render->string
5 render-string->string
4 ;; Configuration 6 ;; Configuration
5 render-specials 7 render-specials
6 render-unprintables 8 render-unprintables
diff --git a/schmaltz.sls b/schmaltz.sls index 4afcf40..c47467a 100644 --- a/schmaltz.sls +++ b/schmaltz.sls
@@ -46,6 +46,18 @@
46 (lambda (port) 46 (lambda (port)
47 (render env port)))))) 47 (render env port))))))
48 48
49(define (render->string . args)
50 (call-with-port (open-output-string)
51 (lambda (out)
52 (apply render args)
53 (get-output-string out))))
54
55(define (render-string->string str . args)
56 (call-with-port (open-output-string)
57 (lambda (out)
58 (apply render-string args)
59 (get-output-string out))))
60
49;;; Configuration 61;;; Configuration
50 62
51(define render-environment 63(define render-environment
@@ -83,3 +95,4 @@
83 95
84(define (unprintable/backtrack ch) 96(define (unprintable/backtrack ch)
85 (list ch #\#)) 97 (list ch #\#))
98 (display (list->string (reverse acc))))