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-springest-0.6.4 guides/rails-render-inline.md
rubocop-springest-0.6.3 guides/rails-render-inline.md
rubocop-github-0.12.0 guides/rails-render-inline.md
rubocop-github-0.11.0 guides/rails-render-inline.md
rubocop-shakr-0.6.0 guides/rails-render-inline.md
rubocop-shakr-0.5.0 guides/rails-render-inline.md
rubocop-springest-0.6.2 guides/rails-render-inline.md
rubocop-springest-0.6.1 guides/rails-render-inline.md
rubocop-github-0.10.0 guides/rails-render-inline.md
rubocop-github-0.9.1 guides/rails-render-inline.md
rubocop-github-0.9.0 guides/rails-render-inline.md
rubocop-github-0.8.1 guides/rails-render-inline.md
rubocop-github-0.8.0 guides/rails-render-inline.md
rubocop-github-0.7.0 guides/rails-render-inline.md
rubocop-github-0.6.0 guides/rails-render-inline.md
rubocop-springest-0.6.0 guides/rails-render-inline.md
rubocop-github-0.5.0 guides/rails-render-inline.md
rubocop-shakr-0.1.0 guides/rails-render-inline.md
rubocop-github-0.4.2 guides/rails-render-inline.md