updates
parent
14369f6c0f
commit
b19d763621
@ -0,0 +1,24 @@
|
|||||||
|
#lang scribble/manual
|
||||||
|
|
||||||
|
@(require scribble/eval pollen/cache pollen/world (for-label racket (except-in pollen #%module-begin) pollen/template pollen/render xml))
|
||||||
|
|
||||||
|
@(define my-eval (make-base-eval))
|
||||||
|
@(my-eval `(require pollen pollen/template xml))
|
||||||
|
|
||||||
|
@title{Template}
|
||||||
|
|
||||||
|
@defmodule[pollen/template]
|
||||||
|
|
||||||
|
Convenience functions for templates. These are automatically imported into the @racket[eval] environment when rendering with a template (see @racket[render]).
|
||||||
|
|
||||||
|
@defproc[
|
||||||
|
(->html
|
||||||
|
[tx txexpr?])
|
||||||
|
string?]
|
||||||
|
Convert @racket[_tx] to an HTML string. Consistent with the HTML spec (and unlike @racket[xexpr->string]), text that appears within @code{script} or @code{style} blocks will not be escaped.
|
||||||
|
|
||||||
|
@examples[#:eval my-eval
|
||||||
|
(define tx '(root (script "3 > 2") "Why is 3 > 2?"))
|
||||||
|
(xexpr->string tx)
|
||||||
|
(->html tx)
|
||||||
|
]
|
@ -0,0 +1,37 @@
|
|||||||
|
#lang racket/base
|
||||||
|
(require rackunit racket/path pollen/cache pollen/file)
|
||||||
|
(require "../template.rkt")
|
||||||
|
|
||||||
|
|
||||||
|
(check-equal? (put '(foo "bar")) '(foo "bar"))
|
||||||
|
(check-equal? (put "tests/template/put.pd")
|
||||||
|
'(root "\n" "\n" (em "One") " paragraph" "\n" "\n" "Another " (em "paragraph") "\n" "\n"))
|
||||||
|
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(check-false (puttable-item? #t))
|
||||||
|
(check-false (puttable-item? #f)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(parameterize ([current-directory "tests/template"])
|
||||||
|
(check-false (find "nonexistent-key" "put"))
|
||||||
|
(check-equal? (find "foo" "put") "bar")
|
||||||
|
(check-equal? (find "em" "put") "One"))
|
||||||
|
(check-equal? (find "foo" #f) #f)
|
||||||
|
|
||||||
|
(parameterize ([current-directory "tests/template"])
|
||||||
|
(check-equal? (find-in-metas "put" "foo") (list "bar"))
|
||||||
|
(let* ([metas (cached-require (->markup-source-path 'put) 'metas)]
|
||||||
|
[here (find-in-metas 'put 'here)])
|
||||||
|
(check-equal? here (list "tests/template/put"))))
|
||||||
|
|
||||||
|
|
||||||
|
(parameterize ([current-directory "tests/template"])
|
||||||
|
(check-false (find-in-doc "put" "nonexistent-key"))
|
||||||
|
(check-equal? (find-in-doc "put" "em") (list "One" "paragraph")))
|
||||||
|
|
||||||
|
(check-equal? (splice '(p "foo" "bar")) (list "foo" "bar"))
|
||||||
|
(check-equal? (splice (list "foo" "bar")) (list "foo" "bar"))
|
||||||
|
(check-equal? (splice "foo") (list "foo"))
|
Loading…
Reference in New Issue