algolia / frontman

💎 A Ruby-based static website generator
https://rubygems.org/gems/frontman-ssg
MIT License
109 stars 4 forks source link

fix: bug with nested content_for #43

Closed DevinCodes closed 3 years ago

DevinCodes commented 3 years ago
Q A
Bug fix? yes
New feature? no

Description

This fixes an issue when we call content_for within a content_for block when using HAML. The issue arises from each block using the same Context class. This meant that it's trying to access the same buffer, and the second content_for block resets the buffer, resulting in an empty buffer for the first content_for block, and therefore no content.

We fixed this by keeping track of a buffer hash for each time we need to save, retrieve, and empty the buffer.

Tested

See tests in spec/frontman/helpers/render_helper_spec.rb.