winton/stasis — Issue #19: Ignore causes doc to be rendered without layout
Author: vivekrajan
Created: 2011-10-09 07:19:42+00:00
State: open

I ran into something that might be a bug or maybe I am using it wrong. Please take a look at this.

The problem happens when you render an 'ignored' document from one that is not ignored. If this happens, the doc that is not ignored is rendered without a layout.

Lets say you have this setup

Directory

```
features/
controller.rb
features.textile
index.html.haml

```

Contents of file

index.html.haml

```
= render "features.textile"
```

features.textile
```
h1. Hi from features
```

controller.rb
```
ignore /textile/
```

Running stasis on this causes the index.html.haml to be rendered without a layout. Removing the ignore /textile/ code causes it to render correctly.

I dug down into the code found this

``` ruby

# This event triggers before each file renders through Stasis. It sets the `action`
# layout from the matching layout for `path`.
def before_render
@stasis.action._layout = nil
matches = _match_key?(@layouts, @stasis.path)
matches.each do |(within, layout)|
@stasis.action._layout = layout if _within?(within)
end
end
```

Changing the

```@stasis.action._layout = nil ``` statement to ```@stasis.action._layout ||= nil``` seems to solve the problem.

This works for me but I would like to hear from you if this looks like a good enough fix.

Regards,

Vivek - thankful user of stasis