Skip to content

Commit

Permalink
removing hx-lsp attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
uros-5 committed Dec 14, 2023
1 parent 8b0c566 commit 424a28d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion examples/web/templates/example.j2
@@ -1,2 +1,2 @@
<p class="text-2xl bg-red-400 rounded">hello world</p>
<p class="text-2xl bg-red-400 rounded" hx-lsp="abc def">hello world</p>
<p class="rounded-xl text-3xl">hello world 2</p>
28 changes: 12 additions & 16 deletions src/short_classes.rs
Expand Up @@ -31,30 +31,26 @@ impl Default for ClassIter {
impl ClassContainer {
pub fn add(&mut self, key: String, token: CSSToken) -> Option<String> {
let index = token as usize;
if let Some(map) = self.container.get_mut(index) {
let oldclass = css_to_html(&key);
match map.entry(oldclass) {
Entry::Vacant(entry) => {
if let Some(new) = self.class_name[index].next() {
return Some(entry.insert(new_class(&new)).to_string());
}
}
Entry::Occupied(entry) => {
return Some(entry.get().clone());
let map = self.container.get_mut(index)?;
let oldclass = css_to_html(&key);
match map.entry(oldclass) {
Entry::Vacant(entry) => {
if let Some(new) = self.class_name[index].next() {
return Some(entry.insert(new_class(&new)).to_string());
}
}
Entry::Occupied(entry) => {
return Some(entry.get().clone());
}
}
None
}

pub fn get(&self, key: String, container: CSSToken) -> Option<String> {
let index = container as usize;
if let Some(map) = self.container.get(index) {
if let Some(v) = map.get(&key) {
return Some(v.to_string());
}
}
None
let map = self.container.get(index)?;
let v = map.get(&key)?;
Some(v.to_string())
}

pub fn into_file(&self, stylesheet: StyleSheet) {
Expand Down
1 change: 1 addition & 0 deletions src/visit_class.rs
Expand Up @@ -25,6 +25,7 @@ pub fn check_html(
.collect::<Vec<String>>()
.join(" ");
let _r = el.set_attribute("class", &classes);
el.remove_attribute("hx-lsp");

Ok(())
})],
Expand Down
7 changes: 3 additions & 4 deletions src/visit_map.rs
Expand Up @@ -46,10 +46,9 @@ pub fn check_js(
Some(&mut srcmap),
),
};
if let Some(module) = program.as_script() {
if emitter.emit_script(module).is_ok() {
return Some(code);
}
let module = program.as_script()?;
if emitter.emit_script(module).is_ok() {
return Some(code);
}
None
}
Expand Down

0 comments on commit 424a28d

Please sign in to comment.