Skip to content

Commit 0dc2318

Browse files
committed
More/better examples in README
1 parent 4133747 commit 0dc2318

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,42 @@ end
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
9999
class 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
109131
end
110132
```

0 commit comments

Comments
 (0)