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

Can’t access text content of now-binary rep #1035

Closed
ddfreyne opened this Issue Dec 24, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@ddfreyne
Member

ddfreyne commented Dec 24, 2016

The binary-ness of an item is determined from the :last snapshot, rather than the snapshot that is being requested. It is therefore not possible to access the textual content of a textual snapshot, if the item’s :last snapshot is binary.

Steps to reproduce

Given:

  • File content/foo.md with content [<%= @items["/bar.*"].compiled_content(snapshot: :raw) %>]

  • File content/bar.md with content 'I am bar!'

  • File Rules:

    compile '/bar.*' do
      filter :text2bin
    end
    
    compile '/foo.*' do
      filter :erb
    end
  • File lib/default.rb:

    Class.new(Nanoc::Filter) do
      identifier :gh_1031_text2bin
      type :text => :binary
    
      def run(content, params = {})
        File.write(output_filename, content)
      end
    end

When: compiling

Then: Nanoc throws a “cannot access binary content” error.

Nanoc should return the textual content instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment