Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beeswax templates fail to splice @ forms #12

Closed
benknoble opened this issue Aug 21, 2021 · 11 comments
Closed

beeswax templates fail to splice @ forms #12

benknoble opened this issue Aug 21, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@benknoble
Copy link

benknoble commented Aug 21, 2021

I've got a sample based on the second pollen tutorial: https://gist.github.com/benknoble/44a83076ab2c9091e4794274c9214ca8 (see second revision).

Notice the '(@) and blank lines where there should be data, as in the pollen version.

There are workarounds in some (but probably not all) cases, and it would be nice if this were fixed. (Also, when the body is a call to a tag function that produces a txexpr, it's not HTML-ified right, though I admit I don't have an example of that.)

@otherjoel otherjoel added the bug Something isn't working label Aug 22, 2021
@otherjoel
Copy link
Owner

Welp, that’s a problem! Thanks for the report.

@otherjoel otherjoel changed the title beeswax templates cannot use when/splice correctly beeswax templates fail to splice @ forms Aug 22, 2021
@otherjoel
Copy link
Owner

Looks like there are multiple problems happening here.

  1. Beeswax needs to do a little work to recognize and splice @ forms when they appear directly in templates.
  2. Beeswax isn’t initializing the current-pagetree parameter as Pollen does (which is why your previous and next expressions aren’t working).

@otherjoel
Copy link
Owner

Also, when the body is a call to a tag function that produces a txexpr, it's not HTML-ified right, though I admit I don't have an example of that.

Can you explain further? Tagged x-expressions usually need to be converted by calling ->html; this doesn’t happen automatically (in Pollen or Beeswax).

@benknoble
Copy link
Author

Can you explain further? Tagged x-expressions usually need to be converted by calling ->html; this doesn’t happen automatically (in Pollen or Beeswax).

I'll do some thinking and try to come up with an example, but I'm reasonably sure that with pollen a txexpr? result of when/splice is HTML-ified, and with Beeswax it's treated as you say. (In all other cases I agree with what you said.) I may be wrong, so I'll double check.

@otherjoel
Copy link
Owner

Thanks for your patience @benknoble — it’s been a busy week! I don’t know how long it will take the package server to reflect these commits but once they do you should be able to raco pkg update beeswax and verify things now work as you expect.

@benknoble
Copy link
Author

Thanks for working on this! Excited to test it out.

@benknoble
Copy link
Author

Hey @otherjoel, sorry it's been so long (new job).

I was testing this by doing raco pkg update beeswax and then raco pollen render and raco beeswax render with the same files from that gist. I ended up with the following diff after moving all the files to the same names:

diff --git i/beeswax-render-article.html w/beeswax-render-article.html
index 3adba27..2aeac28 100644
--- i/beeswax-render-article.html
+++ w/beeswax-render-article.html
@@ -6,8 +6,8 @@
 <body><root><h1 id="deep-thought">Deep Thought</h1><p>I am <strong>so</strong> happy to be writing this.</p></root>
 The current page is called article.html.
 
-'(@)
 
-'(@)
+
+
 </body>
 </html>
\ No newline at end of file
diff --git i/beeswax-render-barticle.html w/beeswax-render-barticle.html
index b5c54fd..4b49597 100644
--- i/beeswax-render-barticle.html
+++ w/beeswax-render-barticle.html
@@ -6,8 +6,8 @@
 <body><root><h1 id="barticle-title">Barticle Title</h1><p>The wonderful second part of the article.</p></root>
 The current page is called barticle.html.
 
-'(@)
 
-'(@)
+
+
 </body>
 </html>
\ No newline at end of file
diff --git i/beeswax-render-carticle.html w/beeswax-render-carticle.html
index 670f787..3c74762 100644
--- i/beeswax-render-carticle.html
+++ w/beeswax-render-carticle.html
@@ -6,8 +6,8 @@
 <body><root><h1 id="carticle-title">Carticle Title</h1><p>The terrific third part.</p></root>
 The current page is called carticle.html.
 
-'(@)
 
-'(@)
+
+
 </body>
 </html>
\ No newline at end of file

It looks like this did make the splicing generate empty lines instead of txeprs, but didn't fix the navigation stuff. (Also, I've realized the format of that gist isn't super clear: all the beeswax-render-{,b,c}article files were produced by raco beeswax render *.pmd. The ones with pollen-render in their name were produced without the pollen.rkt in that directory using raco pollen render. I'm going to update it to make it a little easier to follow, including with this diff.)

@otherjoel
Copy link
Owner

OK I see what’s going on. Any defines get moved to the top of the apply-template function that Beeswax wraps around the template. It so happens that the place they get put is outside the scope of the parameterize that sets the value of the current-pagetree.

You can see this for yourself by removing the definitions of prev-page and next-page and just calling (previous here) and (next here) directly on those lines.

Obviously this is a bug, should be an easy fix. I've opened #16 to track this separately.

(Congrats on the new job!)

@otherjoel
Copy link
Owner

And fixed! The package server updated overnight. @benknoble let me know how it looks for you after a raco pkg update beeswax and (from inside the project folder) raco pollen reset.

@benknoble
Copy link
Author

Will do!

@benknoble
Copy link
Author

And, huge thanks for putting the time in on this ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants