> On Mar 15, 2018, at 11:49 AM, Joel Dueck <dueckofe...@gmail.com> wrote:
> 
> In fine, what interests me is smaller templates reusable within multiple 
> "main" templates, the ones that Pollen grabs and applies to the markup 
> source. And I like that Pollen gives me include-template as an option for 
> doing this.

I see what you mean, though wouldn't `file->string` suffice? Here, we turn the 
main template into a `pp` file so the Pollen commands therein get executed. 
These commands bring in subtemplates with other Pollen commands, but those 
commands don't get executed until "index.html.pm" is rendered with the 
resulting "template.html" as its template: 

;; index.html.pm
#lang pollen
◊(define-meta title "foobar")
Hi there

;; template.html.pp
#lang pollen
◊(require racket/file)
<html>
◊file->string["head.html"]
◊file->string["body.html"]
</html>

;; head.html
<head>
   <title>◊(select-from-metas 'title here)</title>
   <link rel="stylesheet" href="/style.css">
</head>

;; body.html
<body>
<h1>Chapters</h1>
◊(->html doc)
</body>


BTW1 I concede this method calls for some finesse in terms of remembering which 
◊ commands get executed when. 

BTW2 Your question is fair. I've thought along similar lines. At an earlier 
stage in Pollen's life I implemented a special template dialect that would 
allow templates to have templates. Genetic residue here [1] It would've used a 
different command character so the two rounds of Pollen commands would stay 
distinct. But that also seemed possibly like playing 12-dimensional chess. 
Though maybe its time has come.

BTW3 All that said, `include-template` isn't wrong, but in my experience it can 
be slow, so if there's a sleeker solution, so much the better for everyone.


> The case `in` makes for itself [1] is that it shortens a template like this:


Could you post a full working example as a gist or equiv so I can fiddle with 
it? 



[1] 
https://docs.racket-lang.org/pollen/Setup.html?q=pollen%2Fsetup#%28def._%28%28lib._pollen%2Fsetup..rkt%29._setup~3atemplate-source-ext%29%29
 
<https://docs.racket-lang.org/pollen/Setup.html?q=pollen/setup#(def._((lib._pollen/setup..rkt)._setup~3atemplate-source-ext))>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to