Second tutorial: #lang line appears in output with custom template #146

Closed
opened 8 years ago by clartaq · 3 comments
clartaq commented 8 years ago (Migrated from github.com)

Working through the tutorials, it is unclear if fallback.html.p should start with a #lang pollen statement. I have assumed so since it is a pollen file and DrRacket does not provide the button to insert the lozenge character without it. It does not have the line in the tutorial though.

However, when the #lang pollen line is included, it appears as the first line in the output. Things actually work fine without it, but there is no way to insert the lozenge without resorting to keyboard calisthenics.

Could you clarify the intention for this type of file?

Windows 10 Pro, 64-bit
Racket 6.9
Pollen 1.2.1380.975

Working through the tutorials, it is unclear if `fallback.html.p` should start with a `#lang pollen` statement. I have assumed so since it is a pollen file and DrRacket does not provide the button to insert the lozenge character without it. It does not have the line in the tutorial though. However, when the `#lang pollen` line is included, it appears as the first line in the output. Things actually work fine without it, but there is no way to insert the lozenge without resorting to keyboard calisthenics. Could you clarify the intention for this type of file? Windows 10 Pro, 64-bit Racket 6.9 Pollen 1.2.1380.975
clartaq commented 8 years ago (Migrated from github.com)

I meant template.html.p too.

I meant `template.html.p` too.
mbutterick commented 8 years ago (Migrated from github.com)

On May 28, 2017, at 5:09 AM, clartaq notifications@github.com wrote:

Working through the tutorials, it is unclear if fallback.html.p should start with a #lang pollen statement. I have assumed so since it is a pollen file and DrRacket does not provide the button to insert the lozenge character without it. It does not have the line in the tutorial though.

Correct. Template files do not start with #lang pollen.

Here's how I explain it in the docs: [1]

“So a template is also a Pollen source file?” Not quite. More accurately, it’s a fragment of Pollen source that is completed by adding the X-expression that comes out of one of your source files. Because of this, there are a few extra limitations on the code you can put in a template, though with easy workarounds (for instance, you can’t use require in a template, but you can use local-require, which accomplishes the same thing).

However, when the #lang pollen line is included, it appears as the first line in the output. Things actually work fine without it, but there is no way to insert the lozenge without resorting to keyboard calisthenics.

Yes, that is a shortcoming. I don't love the way Pollen templates work, but I haven't figured out a better way. (It would be nice to make them work the same way a self-contained source files, but because they are, by design, not self-contained source files, it's difficult.)

As a workaround, I suppose you can just copy and paste the lozenge. Or put #lang pollen at the top temporarily just to show the button, and remove it when you're done editing the template.

[1] http://docs.racket-lang.org/pollen/second-tutorial.html#%28part.tutorial-2..Templates%29 http://docs.racket-lang.org/pollen/second-tutorial.html#(part._tutorial-2._.Templates)

> On May 28, 2017, at 5:09 AM, clartaq <notifications@github.com> wrote: > > Working through the tutorials, it is unclear if fallback.html.p should start with a #lang pollen statement. I have assumed so since it is a pollen file and DrRacket does not provide the button to insert the lozenge character without it. It does not have the line in the tutorial though. > Correct. Template files do *not* start with `#lang pollen`. Here's how I explain it in the docs: [1] “So a template is also a Pollen source file?” Not quite. More accurately, it’s a fragment of Pollen source that is completed by adding the X-expression that comes out of one of your source files. Because of this, there are a few extra limitations on the code you can put in a template, though with easy workarounds (for instance, you can’t use `require` in a template, but you can use `local-require`, which accomplishes the same thing). > However, when the #lang pollen line is included, it appears as the first line in the output. Things actually work fine without it, but there is no way to insert the lozenge without resorting to keyboard calisthenics. > Yes, that is a shortcoming. I don't love the way Pollen templates work, but I haven't figured out a better way. (It would be nice to make them work the same way a self-contained source files, but because they are, by design, not self-contained source files, it's difficult.) As a workaround, I suppose you can just copy and paste the lozenge. Or put `#lang pollen` at the top temporarily just to show the button, and remove it when you're done editing the template. [1] http://docs.racket-lang.org/pollen/second-tutorial.html#%28part._tutorial-2._.Templates%29 <http://docs.racket-lang.org/pollen/second-tutorial.html#(part._tutorial-2._.Templates)>
clartaq commented 8 years ago (Migrated from github.com)

Thanks for the clarification.

Thanks for the clarification.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#146
Loading…
There is no content yet.