Skip to content

Commit

Permalink
fmt: cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
LastLeaf committed Sep 11, 2024
1 parent 16c985b commit 87f4b19
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
4 changes: 3 additions & 1 deletion glass-easel-template-compiler/src/binding_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ impl BindingMapCollector {
}

pub(crate) fn get_field(&self, field: &str) -> Option<()> {
if self.overall_disabled { return None; }
if self.overall_disabled {
return None;
}
self.fields.get(field).and_then(|x| match x {
BindingMapField::Mapped(_) => Some(()),
BindingMapField::Disabled => None,
Expand Down
10 changes: 8 additions & 2 deletions glass-easel-template-compiler/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ const RUNTIME_ITEMS: [(&'static str, &'static str); 4] = [
];

const EXTRA_RUNTIME_ITEMS: [(&'static str, &'static str); 2] = [
("a", "function(a){for(var i=0;i<a.length;i++)if(a[i])return a}"),
("b", "function(b){var a=Object.values(b);for(var i=0;i<a.length;i++)if(a[i])return a}"),
(
"a",
"function(a){for(var i=0;i<a.length;i++)if(a[i])return a}",
),
(
"b",
"function(b){var a=Object.values(b);for(var i=0;i<a.length;i++)if(a[i])return a}",
),
];

const WXS_RUNTIME_ITEMS: [(&'static str, &'static str); 2] = [
Expand Down
4 changes: 3 additions & 1 deletion glass-easel-template-compiler/src/parse/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ impl Node {
false
});
let is_whitespace = match &value {
Value::Static { value, .. } => value.trim_matches(super::is_template_whitespace).is_empty(),
Value::Static { value, .. } => {
value.trim_matches(super::is_template_whitespace).is_empty()
}
Value::Dynamic { .. } => false,
};
if !is_whitespace {
Expand Down
39 changes: 31 additions & 8 deletions glass-easel-template-compiler/src/proc_gen/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ impl PathSliceList {
if i > 0 {
write!(w, "||")?;
}
write!(w, "{}", this.to_path_analysis_str(scopes, is_template_data)?)?;
write!(
w,
"{}",
this.to_path_analysis_str(scopes, is_template_data)?
)?;
}
if need_paren {
write!(w, ")")?;
Expand Down Expand Up @@ -210,7 +214,11 @@ impl PathSliceList {
Ok(())
}

fn to_path_analysis_str(&self, scopes: &Vec<ScopeVar>, is_template_data: bool) -> Result<String, TmplError> {
fn to_path_analysis_str(
&self,
scopes: &Vec<ScopeVar>,
is_template_data: bool,
) -> Result<String, TmplError> {
let mut ret = String::new();
for path_slice in self.0.iter() {
match path_slice {
Expand All @@ -235,8 +243,12 @@ impl PathSliceList {
let mut next_need_comma_sep = false;
for (key, sub_pas_str, sub_p) in v.iter() {
let mut sub_s = String::new();
let sub_pas_str =
sub_pas_str.to_path_analysis_str(sub_p, &mut sub_s, scopes, is_template_data)?;
let sub_pas_str = sub_pas_str.to_path_analysis_str(
sub_p,
&mut sub_s,
scopes,
is_template_data,
)?;
if let Some(_) = sub_pas_str {
match key {
Some(key) => {
Expand Down Expand Up @@ -272,8 +284,12 @@ impl PathSliceList {
PathSlice::CombineArr(v, spread) => {
for (sub_pas, sub_p) in spread.iter() {
let mut sub_s = String::new();
let sub_pas_str =
sub_pas.to_path_analysis_str(sub_p, &mut sub_s, scopes, is_template_data)?;
let sub_pas_str = sub_pas.to_path_analysis_str(
sub_p,
&mut sub_s,
scopes,
is_template_data,
)?;
if let Some(_) = sub_pas_str {
write!(ret, "({})!==undefined||", sub_s)?;
}
Expand All @@ -285,7 +301,12 @@ impl PathSliceList {
write!(ret, ",")?;
}
let mut s = String::new();
let sub_pas_str = sub_pas.to_path_analysis_str(sub_p, &mut s, scopes, is_template_data)?;
let sub_pas_str = sub_pas.to_path_analysis_str(
sub_p,
&mut s,
scopes,
is_template_data,
)?;
if let Some(_) = sub_pas_str {
write!(ret, "{}", s)?;
next_need_comma_sep = true;
Expand Down Expand Up @@ -1240,7 +1261,9 @@ impl ExpressionProcGen {
scopes: &Vec<ScopeVar>,
is_template_data: bool,
) -> Result<(), TmplError> {
let pas_str = self.pas.to_path_analysis_str(&self.sub_p, w, scopes, is_template_data)?;
let pas_str = self
.pas
.to_path_analysis_str(&self.sub_p, w, scopes, is_template_data)?;
if let Some(_) = pas_str {
// empty
} else {
Expand Down
3 changes: 2 additions & 1 deletion glass-easel-template-compiler/src/proc_gen/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,8 @@ impl Attribute {
double_brace_location: _,
binding_map_keys,
} => {
let maybe_event_binding = !self.is_model && attr_name_maybe_event_binding(&self.name.name);
let maybe_event_binding =
!self.is_model && attr_name_maybe_event_binding(&self.name.name);
let p = expression.to_proc_gen_prepare(w, scopes)?;
w.expr_stmt(|w| {
write!(w, "if(C||K||")?;
Expand Down

0 comments on commit 87f4b19

Please sign in to comment.