File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed
Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change 9191### Rails Helpers
9292
9393``` ruby
94- Phlexing ::Converter .convert(%( <%= link_to @article.title, @article %>) , component: true )
94+ Phlexing ::Converter .convert(%( <%= link_to "Home", root_path %>) , component: true )
9595```
9696
9797##### Output
9898``` ruby
9999class Component < Phlex ::HTML
100100 include Phlex ::Rails ::Helpers ::LinkTo
101+ include Phlex ::Rails ::Helpers ::Routes
101102
102- def initialize ( article: )
103- @article = article
103+ def template
104+ link_to " Home " , root_path
104105 end
106+ end
107+ ```
108+
109+ ### Private component methods
110+
111+ ``` ruby
112+ Phlexing ::Converter .convert(%( <% if active? %>Active<% else %>Inactive<% end %>) , component: true )
113+ ```
105114
115+ ##### Output
116+ ``` ruby
117+ class Component < Phlex ::HTML
106118 def template
107- link_to @article .title, @article
119+ if active?
120+ text " Active"
121+ else
122+ text " Inactive"
123+ end
124+ end
125+
126+ private
127+
128+ def active? (* args , ** kwargs)
129+ # TODO: Implement me
108130 end
109131end
110132```
You can’t perform that action at this time.
0 commit comments