Skip to content

Commit

Permalink
Document the ability to register custom elements (#263)
Browse files Browse the repository at this point in the history
* Document the ability to register custom elements
  • Loading branch information
mansakondo authored Oct 22, 2022
1 parent b8ceea2 commit ab59cd0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/pages/views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ def template(&content)
end
```
MD

render Markdown.new(<<~MD)
## Registering custom elements
You can register custom elements with the `register_element` macro. The custom element will only be available in the view where it is registered and subclasses of that view.
MD

render Example.new do |e|
e.tab "example.rb", <<~RUBY
class Example < Phlex::View
register_element :trix_editor
def template
trix_editor input: "content", autofocus: true
end
end
RUBY

e.execute "Example.new.call"
end
end
end
end
Expand Down

0 comments on commit ab59cd0

Please sign in to comment.