Skip to content

Commit b4ad8db

Browse files
committed
Rename comp_str variable to component_name
1 parent 3808380 commit b4ad8db

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/render.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -730,26 +730,30 @@ impl<W: std::io::Write> HtmlRenderContext<W> {
730730
component.starts_with(PAGE_SHELL_COMPONENT)
731731
}
732732

733-
async fn handle_component(&mut self, comp_str: &str, data: &JsonValue) -> anyhow::Result<()> {
734-
if Self::is_shell_component(comp_str) {
735-
bail!("There cannot be more than a single shell per page. You are trying to open the {} component, but a shell component is already opened for the current page. You can fix this by removing the extra shell component, or by moving this component to the top of the SQL file, before any other component that displays data.", comp_str);
733+
async fn handle_component(
734+
&mut self,
735+
component_name: &str,
736+
data: &JsonValue,
737+
) -> anyhow::Result<()> {
738+
if Self::is_shell_component(component_name) {
739+
bail!("There cannot be more than a single shell per page. You are trying to open the {} component, but a shell component is already opened for the current page. You can fix this by removing the extra shell component, or by moving this component to the top of the SQL file, before any other component that displays data.", component_name);
736740
}
737741

738-
if comp_str == "log" {
742+
if component_name == "log" {
739743
return handle_log_component(
740744
&self.request_context.source_path,
741745
Some(self.current_statement),
742746
data,
743747
);
744748
}
745749

746-
match self.open_component_with_data(comp_str, &data).await {
750+
match self.open_component_with_data(component_name, &data).await {
747751
Ok(_) => Ok(()),
748-
Err(err) => match HeaderComponent::try_from(comp_str) {
749-
Ok(_) => bail!("The {comp_str} component cannot be used after data has already been sent to the client's browser. \n\
752+
Err(err) => match HeaderComponent::try_from(component_name) {
753+
Ok(_) => bail!("The {component_name} component cannot be used after data has already been sent to the client's browser. \n\
750754
This component must be used before any other component. \n\
751-
To fix this, either move the call to the '{comp_str}' component to the top of the SQL file, \n\
752-
or create a new SQL file where '{comp_str}' is the first component."),
755+
To fix this, either move the call to the '{component_name}' component to the top of the SQL file, \n\
756+
or create a new SQL file where '{component_name}' is the first component."),
753757
Err(()) => Err(err),
754758
},
755759
}
@@ -761,8 +765,8 @@ impl<W: std::io::Write> HtmlRenderContext<W> {
761765
.current_component
762766
.as_ref()
763767
.map(SplitTemplateRenderer::name);
764-
if let Some(comp_str) = new_component {
765-
self.handle_component(comp_str, data).await?;
768+
if let Some(component_name) = new_component {
769+
self.handle_component(component_name, data).await?;
766770
} else if current_component.is_none() {
767771
self.open_component_with_data(DEFAULT_COMPONENT, &JsonValue::Null)
768772
.await?;

0 commit comments

Comments
 (0)