You'll need to surround this with something like:

```ruby
if template.respond_to?(:helper_modules)
  # ...
end
```