Skip to content

Commit f91f0d5

Browse files
committed
fix rendering of components without a shell
Pages where the first component was not "shell" were broken
1 parent 48e2a91 commit f91f0d5

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlpage"
3-
version = "0.6.7"
3+
version = "0.6.8"
44
edition = "2021"
55
description = "A SQL-only web application framework. Takes .sql files and formats the query result using pre-made configurable professional-looking components."
66
keywords = ["web", "sql", "framework"]

src/render.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,29 @@ impl<W: std::io::Write> RenderContext<W> {
141141
},
142142
_ => log::trace!("The first row is not a shell component, so we will render a shell with default properties"),
143143
}
144+
144145
log::debug!("Rendering the shell with properties: {shell_properties}");
145146
shell_renderer.render_start(&mut writer, shell_properties)?;
146147

147-
let current_component_name = initial_component.unwrap_or(DEFAULT_COMPONENT);
148-
log::debug!("Creating the first component in the page: '{current_component_name}'");
149-
let current_component = Self::create_renderer(current_component_name, Arc::clone(&app_state))
148+
let current_component = Self::create_renderer(DEFAULT_COMPONENT, Arc::clone(&app_state))
150149
.await
151-
.with_context(|| format!("Unable to open the rendering context because opening the {current_component_name} component failed"))?;
150+
.with_context(|| format!("Unable to open the rendering context because opening the {DEFAULT_COMPONENT} component failed"))?;
152151

153-
Ok(RenderContext {
152+
let mut initial_context = RenderContext {
154153
app_state,
155154
writer,
156155
current_component,
157156
shell_renderer,
158157
recursion_depth: 0,
159158
current_statement: 1,
160-
})
159+
};
160+
161+
if let Some(component) = initial_component {
162+
log::trace!("The page starts with a component without a shell: {component}");
163+
initial_context.handle_row(&initial_row).await?;
164+
}
165+
166+
Ok(initial_context)
161167
}
162168

163169
#[async_recursion(? Send)]

0 commit comments

Comments
 (0)