Skip to content

Commit

Permalink
fix rendering of components without a shell
Browse files Browse the repository at this point in the history
Pages where the first component was not "shell" were broken
  • Loading branch information
lovasoa committed Jun 7, 2023
1 parent 48e2a91 commit f91f0d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlpage"
version = "0.6.7"
version = "0.6.8"
edition = "2021"
description = "A SQL-only web application framework. Takes .sql files and formats the query result using pre-made configurable professional-looking components."
keywords = ["web", "sql", "framework"]
Expand Down
18 changes: 12 additions & 6 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,29 @@ impl<W: std::io::Write> RenderContext<W> {
},
_ => log::trace!("The first row is not a shell component, so we will render a shell with default properties"),
}

log::debug!("Rendering the shell with properties: {shell_properties}");
shell_renderer.render_start(&mut writer, shell_properties)?;

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

Ok(RenderContext {
let mut initial_context = RenderContext {
app_state,
writer,
current_component,
shell_renderer,
recursion_depth: 0,
current_statement: 1,
})
};

if let Some(component) = initial_component {
log::trace!("The page starts with a component without a shell: {component}");
initial_context.handle_row(&initial_row).await?;
}

Ok(initial_context)
}

#[async_recursion(? Send)]
Expand Down

0 comments on commit f91f0d5

Please sign in to comment.