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

content_for helper disrupts Haml indentation #331

Closed
emarthinsen opened this issue Aug 31, 2013 · 5 comments
Closed

content_for helper disrupts Haml indentation #331

emarthinsen opened this issue Aug 31, 2013 · 5 comments

Comments

@emarthinsen
Copy link

Okay, this is a very strange issue that seems inconsistent and difficult to reproduce. I have one project that this error doesn't occur on and one where it always does.

The error that I get is the typical Haml indentation error. It looks like this:

Haml::SyntaxError: Illegal nesting: nesting within plain text is illegal.

What brings it about is more random. Here is a link to a minimal nanoc site that recreates the issue:

https://s3.amazonaws.com/code_share/indent.zip

Just unzip the file, run bundle, then nanoc compile and you should see the same error.

In the file content/projects/client-1.haml, I use a content_for block to capture some content. It then gets rendered out on the content/portfolio.haml page.

If you get rid of the capture block on the client page, then the error does not go away. If you get rid of where the captured content is rendered out on the portfolio page, then the error does go away. Here's the strange one. If you go into the default layout and remove the line that renders the _ga partial, then the error does go away.

There's an unusual interaction going on that I'm having some difficulty tracking down. Any ideas?

Regards,
Eric

@pavelbeliaev
Copy link

I could not reproduce this bug.

ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]
haml (4.0.3)
nanoc (3.6.4)

Compilation is succesful.

pvb@bood:~/scripts/indent$ nanoc
Loading site data… done
Compiling site…

Site compiled in 0.05s.

@emarthinsen
Copy link
Author

That's very strange. I still get the error. Here are the versions I'm using:

ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin11.4.2]

haml (4.0.3)
nanoc (3.6.4)

Almost exactly the same. Could there be something else that is throwing
this off?

On Thu, Sep 19, 2013 at 5:07 AM, bood-pvb notifications@github.com wrote:

I could not reproduce this bug.

ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]

haml (4.0.3)
nanoc (3.6.4)

Compilation is succesful

pvb@bood:~/scripts/indent$ nanoc
Loading site data… done
Compiling site…

Site compiled in 0.05s.


Reply to this email directly or view it on GitHubhttps://github.com//issues/331#issuecomment-24725790
.

@pavelbeliaev
Copy link

Yes, very strange. Haml is a pure ruby => maybe a problem in the implementation
of ruby interpreter for a specific platform. But in my view, this is unlikely.

Anyway, Exception raise a specific piece of code in haml parser module.
Here it is.

 def plain(line, escape_html = nil)
      if block_opened?
        raise SyntaxError.new(Error.message(:illegal_nesting_plain), @next_line.index)
      end

look the next one

    def block_opened?
      @next_line.tabs > @line.tabs
    end

    def tabs
        @tabs ||= parser.compute_tabs(self)
    end

And so on.

Time to debug )
I think that a little bit of 'puts()' is a best way to understand what's going on.

@denisdefreyne
Copy link
Member

Take a look at PR #337 for some background on this nanoc bug.

@denisdefreyne
Copy link
Member

Fixed as part of #337.

The fix will be included in 3.6.6. If you want to have the fix now, put this in your Gemfile and run bundle up:

gem 'nanoc', :github => 'nanoc/nanoc', :branch => 'release-3.6.x'

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

Successfully merging a pull request may close this issue.

3 participants