Re: [pollen] Templates interlinked within templates interlinked

2018-03-15 Thread Matthew Butterick

> On Mar 15, 2018, at 6:00 AM, Joel Dueck  wrote:
> 
> I was pretty happy to learn about the web-server/templates package, which 
> allows you to include the contents of a template file and have it dropped 
> into the lexical context of the calling site. I’ve often wanted something 
> like this so I could write only a single copy of things like headers and 
> footers, and partials for listing chapters/articles in different contexts, 
> etc.

Pollen templates can do all this too, for a not-very-surprising reason (keep 
reading) ...


> I started fiddling with it in a Pollen project and, come to realize it was 
> working even though I hadn’t `require`d or `provide`d any functions from 
> web-server/template. How is this possible, I think. Some digging revealed 
> that Pollen implements its own `include-template` function—and that it is 
> provided automatically for code inside a Pollen template.

The `include-template` in Pollen is the same one as in `web-server/templates` 
[1] But I copied its source and changed it so that it could return binary files 
(like PDFs), which the usual one cannot.


> have you thought about including it in the docs? It’s pretty useful, and the 
> docs could also help avoid confusion among those who already know about 
> web-server/template. The docs do mention that include-template is used behind 
> the scenes but not that it's also available in Pollen templates. With 
> appropriate warnings about XSS concerns.

I suppose I could. I've just never been clear what could be done with 
`include-template` directly that isn't already possible through existing Pollen 
functions. When you apply a template to a markup source during a render, you're 
already using `include-template`.

> might it also be worth providing or reimplementing web-server/template's `in` 
> function? [2] (maybe it already does so, I confess I haven’t checked yet) And 
> then, perhaps including it in the docs somewhere as well.
Same — I suppose I've always thought that because Pollen has a notion of 
X-expressions and tag functions, they subsume `in` (which, unlike 
`include-template`, does no heavy lifting anyhow)



[1] 
https://github.com/mbutterick/pollen/blob/master/pollen/private/include-template.rkt
 


-- 
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.


[pollen] Templates interlinked within templates interlinked

2018-03-15 Thread Joel Dueck
I was pretty happy to learn about the web-server/templates package, which 
allows you to include the contents of a template file and have it dropped 
into the lexical context of the calling site. I’ve often wanted something 
like this so I could write only a single copy of things like headers and 
footers, and partials for listing chapters/articles in different contexts, 
etc.

I started fiddling with it in a Pollen project and, come to realize it was 
working even though I hadn’t `require`d or `provide`d any functions from 
web-server/template. How is this possible, I think. Some digging revealed 
that Pollen implements its own `include-template` function—and that it is 
provided automatically for code inside a Pollen template.

I guess this is cool? But

   - have you thought about including it in the docs? It’s pretty useful, 
   and the docs could also help avoid confusion among those who already know 
   about web-server/template. The docs do mention that include-template is 
   used behind the scenes but not that it's also available in Pollen 
   templates. With appropriate warnings about XSS concerns.
   - might it also be worth providing or reimplementing 
   web-server/template's `in` function? [2] (maybe it already does so, I 
   confess I haven’t checked yet) And then, perhaps including it in the docs 
   somewhere as well.
   - are there tradeoffs between the `include-template` provided by Pollen 
   and the one in web-server/template?


[1]: 
http://docs.racket-lang.org/web-server/templates.html#%28form._%28%28lib._web-server%2Ftemplates..rkt%29._include-template%29%29
[2]: 
http://docs.racket-lang.org/web-server/templates.html#%28form._%28%28lib._web-server%2Ftemplates..rkt%29._in%29%29

-- 
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.