Skip to content

Commit

Permalink
Merge branch 'main' into reduce_unbound_allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron authored Oct 18, 2023
2 parents f5d3a40 + 6ed8d7f commit e5cbd19
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ nav_order: 5

Rainer Borene

* Improve docs about inline templates interpolation

*Hans Lemuet*

## 3.6.0

* Refer to `helpers` in `NameError` message in development and test environments.
Expand Down
22 changes: 22 additions & 0 deletions docs/guide/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ class InlineErbComponent < ViewComponent::Base
end
```

### Interpolations

When using Slim, interpolations have to be escaped, or they'll be evaluated in the context of the ViewComponent class.

```ruby
class InlineSlimComponent < ViewComponent::Base
slim_template <<~SLIM
p Hello, #{name}!
p Hello, \#{name}!
SLIM

def name
"World"
end
end
```

will render:

<p>Hello InlineSlimComponent!</p>
<p>Hello World!</p>

## Sibling file

Place template file next to the component:
Expand Down

0 comments on commit e5cbd19

Please sign in to comment.