You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sugar/scribble.rkt

18 lines
731 B
Racket

11 years ago
#lang racket
(require (for-syntax racket/base))
11 years ago
(require "coerce/values.rkt")
11 years ago
(provide when/block)
;; improves the syntax for conditional blocks in templates
;; ordinarily it would be @when[condition]{@list{stuff ...}}
;; now it can be @when/block[condition]{stuff ...}
;; has to be a macro otherwise body expressions will be evaluated regardless of condition
;; this is bad: if condition is false, expression should exit
(define-syntax (when/block stx)
(syntax-case stx ()
[(_ condition body ...)
11 years ago
#'(if condition (string-append*
(with-handlers ([exn:fail? (λ(exn) (error (format "when/block: ~a" (exn-message exn))))])
(map ->string (list body ...))))
"")]))