-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble composing several elements #30
Comments
This is a (surprising, but logical) consequence of how Elixir return values and the Ratatouille DSL interact: Elixir functions return the last statement from their So what you are seeing is: def render(model) do # returns the last expr, `view`
view do # extracts both `row`s
row do render_first end
row do render_second end
end
end vs def render_both do # returns the last expr, the second `row`
row do render_first end
row do render_second end
end
def render(model) do
view do
render_both # inserts the last expr from `render_both`
end
end As you call attention to, this semantic difference in how The best way I have found to work around this is by return an array of components: def render_both do
[
row do render_first end,
row do render_second end
]
end To my surprise, using macros did not work. I would have imagine this succeeding, but also only renders the last row: defmacrop render_both do
quote do
row do render_first end
row do render_second end
end
end |
the issue lies in these two lines: ratatouille/lib/ratatouille/view.ex Lines 308 to 309 in cc7b6a3
the workaround i've found is to wrap things in a This code will not work view do
if true do
row do
column size: 4 do
panel(title: "Col1")
end
column size: 4 do
panel(title: "Col2")
end
column size: 4 do
panel(title: "Col3")
end
end
row do
column size: 4 do
panel(title: "Col1")
end
column size: 4 do
panel(title: "Col2")
end
column size: 4 do
panel(title: "Col3")
end
end
end
end This code will work view do
if true do
viewport do
row do
column size: 4 do
panel(title: "Col1")
end
column size: 4 do
panel(title: "Col2")
end
column size: 4 do
panel(title: "Col3")
end
end
row do
column size: 4 do
panel(title: "Col1")
end
column size: 4 do
panel(title: "Col2")
end
column size: 4 do
panel(title: "Col3")
end
end
end
end
end |
|
Not sure If I am just misusing ratatouille or it is not possible but anyway I would like to clarify some behaviour
If I have the following for rendering two panels
I can do it like this and both rows show up as expected:
However, if I do it like this, only the last defined row will ever show up:
It works if I change it to the following:
but then I have a panel and the border, which I don't want.
The text was updated successfully, but these errors were encountered: