add the ability to include in templates
This commit is contained in:
parent
6df697cf26
commit
7419859ffb
10
render.rkt
10
render.rkt
|
@ -114,10 +114,12 @@
|
|||
|
||||
(with-output-to-string (λ () (display "<!doctype html>") (display-xexpr document)))))
|
||||
|
||||
(define (compile-index-scss)
|
||||
(define (compile-index-scss index.scss)
|
||||
(define scss-files (append mathml:scss-files syntax:scss-files))
|
||||
(define top-level-style
|
||||
(string-join (map (λ (x) (format "@import \"~a\";" (path->string x))) scss-files) "\n"))
|
||||
(string-join
|
||||
(cons index.scss (map (λ (x) (format "@import \"~a\";" (path->string x))) scss-files))
|
||||
"\n"))
|
||||
(sass:compile/string top-level-style #t))
|
||||
|
||||
(module+ main
|
||||
|
@ -125,8 +127,8 @@
|
|||
(command-line
|
||||
#:program "meow"
|
||||
#:args (infile outfile)
|
||||
(define-rule (scss [out "index.css"])
|
||||
(~> (compile-index-scss) (write-string out)))
|
||||
(define-rule (scss [out "index.css"] [in "index.scss"])
|
||||
(~> (compile-index-scss (port->string in)) (write-string out)))
|
||||
(define-rule (render [out outfile] [in infile])
|
||||
(~> (read-input-doc in) input-doc->ir-doc ir-doc->page (write-string out)))
|
||||
(generate/execute (list render scss))))
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#lang s-exp "../xtemplate.rkt"
|
||||
|
||||
`(p ()
|
||||
"this was included from another file #uwu the summary is: "
|
||||
,(or (metadata-ref+ metadata 'summary) "no summary :("))
|
|
@ -31,7 +31,8 @@
|
|||
,content-toc)
|
||||
(main
|
||||
()
|
||||
,@content)
|
||||
,@content
|
||||
,(include "include.html.rkt"))
|
||||
;; mathjax polyfill script sentinel -- gets replaced by a script tag for crying doge chrombe
|
||||
;; and with nothing for swole firefox
|
||||
(div ([style "display: none"]) "__X_MATHJAX_POLYFILL_PLACEHOLDER__")))
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/base racket/format racket/list racket/match racket/string
|
||||
(require racket/base racket/format racket/list racket/match racket/runtime-path racket/string
|
||||
racket/splicing
|
||||
"defs.rkt" "util.rkt"
|
||||
syntax/parse syntax/parse/define racket/stxparam
|
||||
(for-syntax racket/base racket/match racket/set))
|
||||
|
||||
(provide (rename-out [x:#%module-begin #%module-begin]
|
||||
[x:#%top #%top])
|
||||
[x:#%top #%top]
|
||||
[x:include include])
|
||||
(except-out (all-from-out racket/base racket/format racket/list racket/match racket/string
|
||||
"defs.rkt" "util.rkt")
|
||||
#%module-begin #%top))
|
||||
|
@ -20,6 +22,13 @@
|
|||
(syntax->datum #'id))]
|
||||
(hash-ref tem 'id))
|
||||
|
||||
(define-syntax-parse-rule (x:include what:string)
|
||||
#:with tem:id (syntax-parameter-value #'template-id)
|
||||
#:with execute-temp:id (car (generate-temporaries '(included-execute)))
|
||||
#:with execute-fn
|
||||
(syntax-local-lift-require #`(rename what execute-temp execute) #'execute-temp)
|
||||
(execute-fn tem))
|
||||
|
||||
(define-syntax-parse-rule (x:#%module-begin body)
|
||||
(#%module-begin
|
||||
(provide execute required-keys)
|
||||
|
|
Loading…
Reference in New Issue