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

Passing Ruby types to parent layouts through content_for #53

Open
moll opened this issue May 11, 2019 · 1 comment
Open

Passing Ruby types to parent layouts through content_for #53

moll opened this issue May 11, 2019 · 1 comment
Labels

Comments

@moll
Copy link

moll commented May 11, 2019

Hey,

I was trying to set a class on the <body> of a parent layout from an intermediate layout. As variables set in a content_for :parent do foo = 42 end don't reach the parent layout, I ended up using the content_for string overload (content_for :class, "page-xyz" and querying it through content_for(@item, :class) in the parent layout). As it internally appends to some ERB/Haml buffer, this works for string variables.

How about generalizing it so one could pass all Ruby types through this mechanism?

This with Nanoc v4.10.1.

@denisdefreyne denisdefreyne transferred this issue from nanoc/nanoc May 18, 2019
@denisdefreyne
Copy link
Member

This is certainly an interesting and useful request, and something I’ve been thinking about in the past. I’d go even further and suggest that not only content_for should handle non-string data, but rather every piece of Nanoc that deals with content could.

Some ideas of non-string data:

  • in-memory binary data (which is different from how Nanoc handles binary data at the moment, which is as a reference to an on-disk file)
  • XML DOM (i.e. parsed)
  • kramdon AST (i.e. parsed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants