Sha256: 34f738de6ff0eeb55e699a32bb74072955fc6b31fb547813986247fa765c5b89

Contents?: true

Size: 850 Bytes

Versions: 39

Compression:

Stored size: 850 Bytes

Contents

# GitHub/RailsRenderInline

tldr; Do not use `render inline:`.

## Rendering plain text

``` ruby
render inline: "Just plain text" # bad
```

The `inline:` option is often misused when plain text is being returned. Instead use `render plain: "Just plain text"`.

## Rendering a dynamic ERB string

String `#{}` interpolation is often misused with `render inline:` instead of using `<%= %>` interpolation. This will lead to a memory leak where an ERB method will be compiled and cached for each invocation of `render inline:`.

``` ruby
render inline: "Hello #{@name}" # bad
```

## Rendering static ERB strings

``` ruby
render inline: "Hello <%= @name %>" # bad
```

If you are passing a static ERB string to `render inline:`, this string is best moved to a `.erb` template under `app/views`. Template files are able to be precompiled at boot time.

Version data entries

39 entries across 39 versions & 3 rubygems

Version Path
rubocop-github-0.19.0 guides/rails-render-inline.md
rubocop-springest-0.7.5 guides/rails-render-inline.md
rubocop-github-0.18.0 guides/rails-render-inline.md
rubocop-github-0.17.0 guides/rails-render-inline.md
rubocop-springest-0.7.4 guides/rails-render-inline.md
rubocop-springest-0.7.3 guides/rails-render-inline.md
rubocop-github-0.16.2 guides/rails-render-inline.md
rubocop-github-0.16.1 guides/rails-render-inline.md
rubocop-springest-0.7.2 guides/rails-render-inline.md
rubocop-github-0.16.0 guides/rails-render-inline.md
rubocop-github-0.15.0 guides/rails-render-inline.md
rubocop-springest-0.7.1 guides/rails-render-inline.md
rubocop-github-0.14.0 guides/rails-render-inline.md
rubocop-springest-0.7.0 guides/rails-render-inline.md
rubocop-springest-0.6.9 guides/rails-render-inline.md
rubocop-springest-0.6.8 guides/rails-render-inline.md
rubocop-github-0.13.0 guides/rails-render-inline.md
rubocop-springest-0.6.7 guides/rails-render-inline.md
rubocop-springest-0.6.6 guides/rails-render-inline.md
rubocop-springest-0.6.5 guides/rails-render-inline.md