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