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

Option for the Capturing helper to do copy-and-paste #67

Open
luc-j-bourhis opened this issue Apr 17, 2023 · 1 comment
Open

Option for the Capturing helper to do copy-and-paste #67

luc-j-bourhis opened this issue Apr 17, 2023 · 1 comment

Comments

@luc-j-bourhis
Copy link

Current behaviour

In its current incarnation, the capturing helper is cut-and-paste. That is to say that the following

<p>Some text before</p>
<% content_for :summary do %>
  <p>On this item, Nanoc is introduced, blah blah.</p>
<% end %>
<p>Some text after</p>

will output

<p>Some text before</p>
<p>Some text after</p>

If one wants the captured text where it was written, one has to paste it right after cutting it

<p>Some text before</p>
<% content_for :summary do %>
  <p>On this item, Nanoc is introduced, blah blah.</p>
<% end %>
<%= content_for(@item, :summary) %>
<p>Some text after</p>

Or course <%= content_for(..., :summary) %> would be used elsewhere!

Desired behavior

But I have a use case where a paragraph is used as an introduction on several different pages. It would be nice to have an option to avoid typing <%= content_for(@item, :summary) %> just after the capturing context. Maybe something like.

<p>Some text before</p>
<% content_for :summary, cut: false do %>
  <p>On this item, Nanoc is introduced, blah blah.</p>
<% end %>
<p>Some text after</p>

which would result in

<p>Some text before</p>
  <p>On this item, Nanoc is introduced, blah blah.</p>
<p>Some text after</p>

as well as capturing the paragraph to be reused elsewhere. I.e. copy-and-paste.

@denisdefreyne
Copy link
Member

I like that idea!

I’ll move it to the nanoc/features repository, where I collect ideas for features and improvements.

If you want to and feel up for it, you can open up a PR. The Capturing helper has a test suite that hopefully should be pretty easy to adjust too.

@denisdefreyne denisdefreyne transferred this issue from nanoc/nanoc Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants