-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f56cb0f
commit da802d9
Showing
5 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
<% if @render_args[:component] %> | ||
<% if defined?(Phlex::SGML) && @render_args[:component].is_a?(Phlex::SGML) %> | ||
<%= raw(@render_args[:component].call(view_context: self, &@render_args[:block])) %> | ||
<% else %> | ||
<%= render(@render_args[:component], @render_args[:args], &@render_args[:block]) %> | ||
<% end %> | ||
<%= render(@render_args[:component], @render_args[:args], &@render_args[:block]) %> | ||
<% else %> | ||
<%= render(@render_args[:template], **@render_args[:locals], &@render_args[:block]) %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Lookbook | ||
class PhlexPreview < Preview | ||
def render(component, &block) | ||
super do | ||
component.instance_exec component, &block | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Views::Phlex | ||
class CardExample < Phlex::HTML | ||
def template(&content) | ||
div class: "card", &content | ||
end | ||
|
||
def footer(&content) | ||
div class: "card-footer", &content | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/dummy/test/components/previews/phlex_dsl_example_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class PhlexDslExamplePreview < Lookbook::PhlexPreview | ||
def default | ||
render Views::Phlex::CardExample.new do |card| | ||
h1 { "My card" } | ||
|
||
div class: "card-body" do | ||
render Views::Phlex::ListExample.new do |list| | ||
list.item { "Hello" } | ||
list.item { "World" } | ||
end | ||
end | ||
|
||
card.footer do | ||
span { "Hey ya!" } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters