Compare commits
5 Commits
aea28850d5
...
9fe91ebd2a
Author | SHA1 | Date |
---|---|---|
xenia | 9fe91ebd2a | |
ashley williams | d2c0379311 | |
Ashley Williams | f6f0a0385d | |
ashley williams | 2b6b7cff64 | |
Ashley Williams | cd0f7f4eb4 |
23
CHANGELOG.md
23
CHANGELOG.md
|
@ -1,5 +1,28 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.5.0 - 2023-03-29
|
||||||
|
|
||||||
|
### 🛠️ Fixes
|
||||||
|
|
||||||
|
- **✨ Fix broken links and naming issues from fork transition- [adrianheine], [pr29]**
|
||||||
|
|
||||||
|
This PR helps clean up a variety of references and links that weren't caught
|
||||||
|
when the project transitioned from a fork of the `typed-html` crate.
|
||||||
|
|
||||||
|
### 🌿 Maintenance
|
||||||
|
|
||||||
|
- **✨ Dependency gardening - [ashleygwilliams], [pr32]/[pr33]**
|
||||||
|
|
||||||
|
General dependency maintenance with two notable actions:
|
||||||
|
|
||||||
|
- replace `ansi_term` with `console` to match the rest of the axo toolchain
|
||||||
|
- update `lalrpop` to 0.19.9 (latest release) to address warning
|
||||||
|
|
||||||
|
[adrianheine]: https://github.com/adrianheine
|
||||||
|
[pr29]: https://github.com/axodotdev/axohtml/pull/29
|
||||||
|
[pr32]: https://github.com/axodotdev/axohtml/pull/32
|
||||||
|
[pr33]: https://github.com/axodotdev/axohtml/pull/33
|
||||||
|
|
||||||
## 0.4.1 - 2023-01-24
|
## 0.4.1 - 2023-01-24
|
||||||
|
|
||||||
### 🛠️ Fixes
|
### 🛠️ Fixes
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "axohtml-macros"
|
name = "axohtml-macros"
|
||||||
version = "0.4.1"
|
version = "0.5.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
authors = ["Axo Developer Co <hello@axo.dev>", "Bodil Stokke <bodil@bodil.org>"]
|
authors = ["Axo Developer Co <hello@axo.dev>", "Bodil Stokke <bodil@bodil.org>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
@ -17,9 +17,9 @@ proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lalrpop-util = "0.19"
|
lalrpop-util = "0.19"
|
||||||
ansi_term = "0.12.1"
|
|
||||||
proc-macro2 = "1.0.54"
|
proc-macro2 = "1.0.54"
|
||||||
quote = "1.0.26"
|
quote = "1.0.26"
|
||||||
|
console = "0.15.5"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lalrpop = "0.19.9"
|
lalrpop = "0.19.9"
|
||||||
|
|
|
@ -103,6 +103,7 @@ impl Declare {
|
||||||
pub attrs: #attr_type_name,
|
pub attrs: #attr_type_name,
|
||||||
pub data_attributes: Vec<(&'static str, String)>,
|
pub data_attributes: Vec<(&'static str, String)>,
|
||||||
pub aria_attributes: Vec<(&'static str, String)>,
|
pub aria_attributes: Vec<(&'static str, String)>,
|
||||||
|
pub htmx_attributes: Vec<(&'static str, String)>,
|
||||||
pub events: T::Events,
|
pub events: T::Events,
|
||||||
#body
|
#body
|
||||||
}
|
}
|
||||||
|
@ -129,6 +130,7 @@ impl Declare {
|
||||||
));
|
));
|
||||||
body.extend(quote!(data_attributes: Vec::new(),));
|
body.extend(quote!(data_attributes: Vec::new(),));
|
||||||
body.extend(quote!(aria_attributes: Vec::new(),));
|
body.extend(quote!(aria_attributes: Vec::new(),));
|
||||||
|
body.extend(quote!(htmx_attributes: Vec::new(),));
|
||||||
|
|
||||||
for (child_name, _, _) in self.req_children() {
|
for (child_name, _, _) in self.req_children() {
|
||||||
body.extend(quote!( #child_name, ));
|
body.extend(quote!( #child_name, ));
|
||||||
|
@ -178,6 +180,7 @@ impl Declare {
|
||||||
#push_attrs
|
#push_attrs
|
||||||
attributes.extend(self.data_attributes.clone());
|
attributes.extend(self.data_attributes.clone());
|
||||||
attributes.extend(self.aria_attributes.clone());
|
attributes.extend(self.aria_attributes.clone());
|
||||||
|
attributes.extend(self.htmx_attributes.clone());
|
||||||
|
|
||||||
let mut children = Vec::new();
|
let mut children = Vec::new();
|
||||||
#req_children
|
#req_children
|
||||||
|
@ -247,6 +250,10 @@ impl Declare {
|
||||||
for (key, value) in &self.aria_attributes {
|
for (key, value) in &self.aria_attributes {
|
||||||
out.push((key, value.to_string()));
|
out.push((key, value.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (key, value) in &self.htmx_attributes {
|
||||||
|
out.push((key, value.to_string()));
|
||||||
|
}
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,6 +371,10 @@ impl Declare {
|
||||||
write!(f, " aria-{}=\"{}\"", key,
|
write!(f, " aria-{}=\"{}\"", key,
|
||||||
crate::escape_html_attribute(value.to_string()))?;
|
crate::escape_html_attribute(value.to_string()))?;
|
||||||
}
|
}
|
||||||
|
for (key, value) in &self.htmx_attributes {
|
||||||
|
write!(f, " {}=\"{}\"", key,
|
||||||
|
crate::escape_html_attribute(value.to_string()))?;
|
||||||
|
}
|
||||||
write!(f, "{}", self.events)?;
|
write!(f, "{}", self.events)?;
|
||||||
#print_children
|
#print_children
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::lexer::Token;
|
use crate::lexer::Token;
|
||||||
use ansi_term::Style;
|
use console::style;
|
||||||
use lalrpop_util::ParseError::*;
|
use lalrpop_util::ParseError::*;
|
||||||
use proc_macro2::{Ident, TokenStream};
|
use proc_macro2::{Ident, TokenStream};
|
||||||
use quote::{quote, quote_spanned};
|
use quote::{quote, quote_spanned};
|
||||||
|
@ -71,7 +71,7 @@ pub fn parse_error(input: &[Token], error: &ParseError) -> TokenStream {
|
||||||
// special case: you probably meant to quote that text
|
// special case: you probably meant to quote that text
|
||||||
let help_msg = format!(
|
let help_msg = format!(
|
||||||
"text nodes need to be quoted, eg. {}",
|
"text nodes need to be quoted, eg. {}",
|
||||||
Style::new().bold().paint("<p>\"Hello Joe!\"</p>")
|
style("<p>\"Hello Joe!\"</p>").bold(),
|
||||||
);
|
);
|
||||||
Some(quote_spanned! {span=>
|
Some(quote_spanned! {span=>
|
||||||
compile_error! { #help_msg }
|
compile_error! { #help_msg }
|
||||||
|
|
|
@ -115,6 +115,21 @@ fn extract_aria_attributes(
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extract_htmx_attrs(attrs: &mut StringyMap<Ident, TokenTree>) -> StringyMap<String, TokenTree> {
|
||||||
|
let mut data = StringyMap::new();
|
||||||
|
let keys: Vec<Ident> = attrs.keys().cloned().collect();
|
||||||
|
for key in keys {
|
||||||
|
let key_name = key.to_string();
|
||||||
|
if key_name.starts_with("hx_") || key_name.starts_with("sse_")
|
||||||
|
|| key_name.starts_with("ws_") {
|
||||||
|
let value = attrs.remove(&key).unwrap();
|
||||||
|
let key = str::replace(&key_name, "_", "-");
|
||||||
|
data.insert(key.to_string(), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data
|
||||||
|
}
|
||||||
|
|
||||||
fn process_value(value: &TokenTree) -> TokenStream {
|
fn process_value(value: &TokenTree) -> TokenStream {
|
||||||
match value {
|
match value {
|
||||||
TokenTree::Group(g) if g.delimiter() == Delimiter::Bracket => {
|
TokenTree::Group(g) if g.delimiter() == Delimiter::Bracket => {
|
||||||
|
@ -165,6 +180,7 @@ impl Element {
|
||||||
let events = extract_event_handlers(&mut self.attributes);
|
let events = extract_event_handlers(&mut self.attributes);
|
||||||
let data_attrs = extract_data_attrs(&mut self.attributes);
|
let data_attrs = extract_data_attrs(&mut self.attributes);
|
||||||
let aria_attrs = extract_aria_attributes(&mut self.attributes);
|
let aria_attrs = extract_aria_attributes(&mut self.attributes);
|
||||||
|
let htmx_attrs = extract_htmx_attrs(&mut self.attributes);
|
||||||
let attrs = self.attributes.iter().map(|(key, value)| {
|
let attrs = self.attributes.iter().map(|(key, value)| {
|
||||||
(
|
(
|
||||||
key.to_string(),
|
key.to_string(),
|
||||||
|
@ -246,6 +262,15 @@ impl Element {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (key, value) in htmx_attrs
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| (TokenTree::from(Literal::string(k)), v.clone()))
|
||||||
|
{
|
||||||
|
body.extend(quote!(
|
||||||
|
element.htmx_attributes.push((#key, #value.into()));
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
body.extend(opt_children);
|
body.extend(opt_children);
|
||||||
|
|
||||||
for (key, value) in events.iter() {
|
for (key, value) in events.iter() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "axohtml"
|
name = "axohtml"
|
||||||
version = "0.4.1"
|
version = "0.5.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Axo Developer Co <hello@axo.dev>", "Bodil Stokke <bodil@bodil.org>"]
|
authors = ["Axo Developer Co <hello@axo.dev>", "Bodil Stokke <bodil@bodil.org>"]
|
||||||
license = "MPL-2.0+"
|
license = "MPL-2.0+"
|
||||||
|
|
|
@ -490,6 +490,16 @@ fn test_aria() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_htmx_attributes() {
|
||||||
|
use crate as axohtml;
|
||||||
|
use crate::{dom::DOMTree, html};
|
||||||
|
|
||||||
|
let frag: DOMTree<String> = html!(<div hx-ext="sse" sse-connect="/test">"Boo!"</div>);
|
||||||
|
|
||||||
|
assert_eq!("<div hx-ext=\"sse\" sse-connect=\"/test\">Boo!</div>", frag.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_js() {
|
fn test_js() {
|
||||||
use crate as axohtml;
|
use crate as axohtml;
|
||||||
|
|
Loading…
Reference in New Issue