diff --git a/Cargo.toml b/Cargo.toml
index 27b17668..a474ca0a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,3 +1,18 @@
+[workspace.dependencies]
+yarte = { path = "yarte", version = "~0.15.7" }
+yarte_codegen = { path = "yarte_codegen", version = "~0.15.7" }
+yarte_derive = { path = "yarte_derive", version = "~0.15.6" }
+yarte_helpers = { path = "yarte_helpers", version = "~0.15.8" }
+yarte_hir = { path = "yarte_hir", version = "~0.15.6" }
+yarte_parser = { path = "yarte_parser", version = "~0.15.2" }
+yarte_lexer = { path = "yarte_lexer", version = "~0.0.1" }
+yarte_rust = { path = "yarte_rust", version = "~0.0.1" }
+yarte_strnom = { path = "yarte_strnom", version = "~0.0.1" }
+
+buf-min = "~0.7.1"
+
+proc-macro2 = { version = "~1.0.66" }
+
[workspace]
resolver = "2"
members = [
@@ -12,14 +27,3 @@ members = [
"yarte_rust",
"yarte_strnom",
]
-[workspace.dependencies]
-yarte_codegen = { path = "yarte_codegen", version = "0.15.7" }
-yarte_derive = { path = "yarte_derive", version = "0.15.6" }
-yarte_helpers = { path = "yarte_helpers", version = "0.15.8" }
-yarte_hir = { path = "yarte_hir", version = "0.15.6" }
-yarte_parser = { path = "yarte_parser", version = "0.15.2" }
-yarte_lexer = { path = "yarte_lexer", version = "0.0.1" }
-yarte_rust = { path = "yarte_rust", version = "0.0.1" }
-yarte_strnom = { path = "yarte_strnom", version = "0.0.1" }
-
-proc-macro2 = { version = "~1.0.66" }
\ No newline at end of file
diff --git a/examples/bytes/Cargo.toml b/examples/bytes/Cargo.toml
index 003084ec..9fa33b95 100644
--- a/examples/bytes/Cargo.toml
+++ b/examples/bytes/Cargo.toml
@@ -8,11 +8,9 @@ edition = "2021"
workspace = "../.."
[dependencies]
-yarte = { path = "../../yarte", version = "*", features = ["bytes-buf"] }
+yarte = { workspace = true, features = ["bytes-buf"] }
-bytes = "1.2.1"
-buf-min = { version = "0.7.0", features = ["bytes"] }
+buf-min = { workspace = true }
[build-dependencies]
-yarte_helpers = { path = "../../yarte_helpers", version = "*" }
-
+yarte_helpers = { workspace = true }
diff --git a/examples/bytes/src/main.rs b/examples/bytes/src/main.rs
index a28de4e8..e2ea9bb2 100644
--- a/examples/bytes/src/main.rs
+++ b/examples/bytes/src/main.rs
@@ -1,26 +1,24 @@
#![cfg_attr(nightly, feature(proc_macro_hygiene, stmt_expr_attributes))]
-use std::collections::HashMap;
+
use std::io::{stdout, Write};
use yarte::*;
-use bytes::BytesMut;
-
struct Card<'a> {
title: &'a str,
body: &'a str,
}
-#[cfg(nightly)]
-/// without comma or error
-/// `message: stable/nightly mismatch`
-fn _write_str(buffer: BytesMut) {
- stdout().lock().write_all(&buffer).unwrap();
+fn _write_str(buffer: String) {
+ stdout().lock().write_all(buffer.as_bytes()).unwrap();
}
-#[cfg(nightly)]
-fn nightly(my_card: &Card) {
- let mut buffer = BytesMut::new();
+fn main() {
+ let my_card = Card {
+ title: "My Title",
+ body: "My Body",
+ };
+ let mut buffer = Vec::with_capacity(2048);
#[html(buffer)]
"{{> hello my_card }}";
@@ -37,41 +35,10 @@ fn nightly(my_card: &Card) {
println!();
- let buffer: BytesMut = #[html]
+ let buffer: String = #[html]
"{{> hello my_card }}";
println!("Proc macro attribute auto");
- stdout().lock().write_all(&buffer).unwrap();
- println!();
-}
-
-fn main() {
- let mut query = HashMap::new();
- query.insert("name", "new");
- query.insert("lastname", "user");
-
- let query = query
- .get("name")
- .and_then(|name| query.get("lastname").map(|lastname| (*name, *lastname)));
-
- // Auto sized html minimal (Work in progress. Not use in production)
- let buf = auto!(ywrite!(BytesMut, "{{> index }}"));
-
- println!("Proc macro minimal");
- stdout().lock().write_all(&buf).unwrap();
- println!();
-
- let my_card = Card {
- title: "My Title",
- body: "My Body",
- };
-
- // Auto sized html
- let buf = auto!(ywrite_html!(BytesMut, "{{> hello my_card }}"));
- println!("Proc macro auto");
- stdout().lock().write_all(&buf).unwrap();
+ stdout().lock().write_all(buffer.as_bytes()).unwrap();
println!();
-
- #[cfg(nightly)]
- nightly(&my_card);
}
diff --git a/examples/bytes/templates/base.hbs b/examples/bytes/templates/base.hbs
deleted file mode 100644
index 34d78df6..00000000
--- a/examples/bytes/templates/base.hbs
+++ /dev/null
@@ -1,8 +0,0 @@
-{{! Simple example !}}
-{{> doc/t }}
-
-{{> doc/head }}
-
-{{> @partial-block }}
-
-
diff --git a/examples/bytes/templates/deep/more/card/form.hbs b/examples/bytes/templates/deep/more/card/form.hbs
deleted file mode 100644
index 75b0c84a..00000000
--- a/examples/bytes/templates/deep/more/card/form.hbs
+++ /dev/null
@@ -1,16 +0,0 @@
-{{!
- Form: What is your name?
-!}}
-{{> ../deep/welcome id = "welcome", tag = "h1", tail = '!' ~}}
-
diff --git a/examples/bytes/templates/deep/more/card/hi.hbs b/examples/bytes/templates/deep/more/card/hi.hbs
deleted file mode 100644
index 7bd929f1..00000000
--- a/examples/bytes/templates/deep/more/card/hi.hbs
+++ /dev/null
@@ -1,8 +0,0 @@
-{{!
- Hi message:
- args:
- - lastname
- - name
-!}}
-Hi, {{ name }} {{ lastname }}!
-{{~> alias/welcome id = "hi", tag = 'p', tail = "" }}
diff --git a/examples/bytes/templates/deep/more/deep/welcome.hbs b/examples/bytes/templates/deep/more/deep/welcome.hbs
deleted file mode 100644
index fea7606d..00000000
--- a/examples/bytes/templates/deep/more/deep/welcome.hbs
+++ /dev/null
@@ -1,11 +0,0 @@
-{{!
- Welcome card:
- args:
- - tag
- - id
- - tail
-!}}
-{{#unless tag.is_match(r"^p|(h[1-6])$") && !id.is_empty() }}
- {{$ "Need static args: tag: str /^h[1-6]$/, id: str" }}
-{{/unless }}
-<{{ tag }} id="{{ id }}" class="welcome">Welcome{{ tail }}{{ tag }}>
diff --git a/examples/bytes/templates/deep/more/doc/head.hbs b/examples/bytes/templates/deep/more/doc/head.hbs
deleted file mode 100644
index 20764911..00000000
--- a/examples/bytes/templates/deep/more/doc/head.hbs
+++ /dev/null
@@ -1,7 +0,0 @@
-{{# unless title.is_str() && !title.is_empty() }}
- {{$ "Need static args: title: str" }}
-{{/unless}}
-
-
- {{ title }}
-
diff --git a/examples/bytes/templates/deep/more/doc/t.hbs b/examples/bytes/templates/deep/more/doc/t.hbs
deleted file mode 100644
index 0e76edd6..00000000
--- a/examples/bytes/templates/deep/more/doc/t.hbs
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/examples/bytes/templates/index.hbs b/examples/bytes/templates/index.hbs
deleted file mode 100644
index dc1fbc16..00000000
--- a/examples/bytes/templates/index.hbs
+++ /dev/null
@@ -1,7 +0,0 @@
-{{#> base title = "Actix web" }}
- {{~#if let Some((name, lastname)) = query ~}}
- {{> card/hi ~}}
- {{ else ~}}
- {{> card/form ~}}
- {{/if ~}}
-{{/base }}
diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml
deleted file mode 100644
index 51e6216b..00000000
--- a/examples/simple/Cargo.toml
+++ /dev/null
@@ -1,15 +0,0 @@
-[package]
-name = "simple"
-version = "0.0.1"
-authors = ["Juan Aguilar Santillana "]
-publish = false
-edition = "2021"
-
-workspace = "../.."
-
-[dependencies]
-yarte = { path = "../../yarte", version = "*", features = ["bytes-buf"] }
-
-[build-dependencies]
-yarte = { path = "../../yarte", version = "*" }
-yarte_helpers = { path = "../../yarte_helpers", version = "*" }
diff --git a/examples/simple/build.rs b/examples/simple/build.rs
deleted file mode 100644
index 44f5a322..00000000
--- a/examples/simple/build.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-fn main() {
- yarte::recompile::when_changed();
- if !yarte_helpers::definitely_not_nightly() {
- println!("cargo:rustc-cfg=nightly");
- }
-}
diff --git a/examples/simple/src/main.rs b/examples/simple/src/main.rs
deleted file mode 100644
index 94dd58a8..00000000
--- a/examples/simple/src/main.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-#![cfg_attr(nightly, feature(proc_macro_hygiene, stmt_expr_attributes))]
-use std::collections::HashMap;
-use std::io::{stdout, Write};
-
-use yarte::*;
-
-struct Card<'a> {
- title: &'a str,
- body: &'a str,
-}
-
-#[cfg(nightly)]
-/// without comma or error
-/// `message: stable/nightly mismatch`
-fn _write_str(buffer: String) {
- stdout().lock().write_all(buffer.as_bytes()).unwrap();
-}
-
-#[cfg(nightly)]
-fn nightly(my_card: &Card) {
- let mut buffer = String::new();
- // TODO: unexpected token `;`, bad statement when pass without let
- let _ = #[html(buffer)]
- "{{> hello my_card }}";
-
- #[cfg(nightly)]
- "Why this runs and not the above";
-
- println!("Proc macro attribute");
- stdout().lock().write_all(buffer.as_bytes()).unwrap();
- println!();
-
- println!("Proc macro attribute auto");
-
- // without comma or error
- // `message: stable/nightly mismatch`
- #[rustfmt::skip]
- _write_str(#[html] "{{> hello my_card }}");
-
- println!();
-
- let buffer: Vec = #[html]
- "{{> hello my_card }}";
-
- println!("Proc macro attribute auto");
- stdout().lock().write_all(&buffer).unwrap();
- println!();
-}
-
-fn main() {
- let mut query = HashMap::new();
- query.insert("name", "new");
- query.insert("lastname", "user");
-
- let query = query
- .get("name")
- .and_then(|name| query.get("lastname").map(|lastname| (*name, *lastname)));
-
- // Auto sized html minimal (Work in progress. Not use in production)
- let buf = auto!(ywrite!(String, "{{> index }}"));
-
- println!("Proc macro minimal");
- stdout().lock().write_all(buf.as_bytes()).unwrap();
- println!();
-
- let my_card = Card {
- title: "My Title",
- body: "My Body",
- };
-
- // Auto sized html
- let buf = auto!(ywrite_html!(String, "{{> hello my_card }}"));
- println!("Proc macro auto");
- stdout().lock().write_all(buf.as_bytes()).unwrap();
- println!();
-
- #[cfg(nightly)]
- nightly(&my_card);
-}
diff --git a/examples/simple/templates/base.hbs b/examples/simple/templates/base.hbs
deleted file mode 100644
index 34d78df6..00000000
--- a/examples/simple/templates/base.hbs
+++ /dev/null
@@ -1,8 +0,0 @@
-{{! Simple example !}}
-{{> doc/t }}
-
-{{> doc/head }}
-
-{{> @partial-block }}
-
-
diff --git a/examples/simple/templates/deep/more/card/form.hbs b/examples/simple/templates/deep/more/card/form.hbs
deleted file mode 100644
index 75b0c84a..00000000
--- a/examples/simple/templates/deep/more/card/form.hbs
+++ /dev/null
@@ -1,16 +0,0 @@
-{{!
- Form: What is your name?
-!}}
-{{> ../deep/welcome id = "welcome", tag = "h1", tail = '!' ~}}
-
diff --git a/examples/simple/templates/deep/more/card/hi.hbs b/examples/simple/templates/deep/more/card/hi.hbs
deleted file mode 100644
index 7bd929f1..00000000
--- a/examples/simple/templates/deep/more/card/hi.hbs
+++ /dev/null
@@ -1,8 +0,0 @@
-{{!
- Hi message:
- args:
- - lastname
- - name
-!}}
-Hi, {{ name }} {{ lastname }}!
-{{~> alias/welcome id = "hi", tag = 'p', tail = "" }}
diff --git a/examples/simple/templates/deep/more/deep/welcome.hbs b/examples/simple/templates/deep/more/deep/welcome.hbs
deleted file mode 100644
index fea7606d..00000000
--- a/examples/simple/templates/deep/more/deep/welcome.hbs
+++ /dev/null
@@ -1,11 +0,0 @@
-{{!
- Welcome card:
- args:
- - tag
- - id
- - tail
-!}}
-{{#unless tag.is_match(r"^p|(h[1-6])$") && !id.is_empty() }}
- {{$ "Need static args: tag: str /^h[1-6]$/, id: str" }}
-{{/unless }}
-<{{ tag }} id="{{ id }}" class="welcome">Welcome{{ tail }}{{ tag }}>
diff --git a/examples/simple/templates/deep/more/doc/head.hbs b/examples/simple/templates/deep/more/doc/head.hbs
deleted file mode 100644
index 20764911..00000000
--- a/examples/simple/templates/deep/more/doc/head.hbs
+++ /dev/null
@@ -1,7 +0,0 @@
-{{# unless title.is_str() && !title.is_empty() }}
- {{$ "Need static args: title: str" }}
-{{/unless}}
-
-
- {{ title }}
-
diff --git a/examples/simple/templates/deep/more/doc/t.hbs b/examples/simple/templates/deep/more/doc/t.hbs
deleted file mode 100644
index 0e76edd6..00000000
--- a/examples/simple/templates/deep/more/doc/t.hbs
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/examples/simple/templates/hello.hbs b/examples/simple/templates/hello.hbs
deleted file mode 100644
index 51364f83..00000000
--- a/examples/simple/templates/hello.hbs
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
{{title}}
-
- {{body}}
-
-
diff --git a/examples/simple/templates/index.hbs b/examples/simple/templates/index.hbs
deleted file mode 100644
index dc1fbc16..00000000
--- a/examples/simple/templates/index.hbs
+++ /dev/null
@@ -1,7 +0,0 @@
-{{#> base title = "Actix web" }}
- {{~#if let Some((name, lastname)) = query ~}}
- {{> card/hi ~}}
- {{ else ~}}
- {{> card/form ~}}
- {{/if ~}}
-{{/base }}
diff --git a/examples/simple/yarte.toml b/examples/simple/yarte.toml
deleted file mode 100644
index e13a39b9..00000000
--- a/examples/simple/yarte.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-# root dir of templates
-[main]
-dir = "templates"
-
-# Alias for partials. In call, change the start of partial path with one of this, if exist.
-[partials]
-alias = "./deep/more/deep"
-doc = "./deep/more/doc"
-card = "./deep/more/card"
-
-[debug]
-# prettyprint themes, put anything for options
-theme = "zenburn"
-grid = true
-header = true
-number_line = true
-paging = false
-short = false
diff --git a/yarte/Cargo.toml b/yarte/Cargo.toml
index 75176c2e..c89340d6 100644
--- a/yarte/Cargo.toml
+++ b/yarte/Cargo.toml
@@ -25,7 +25,7 @@ bytes-buf = ["buf-min", "yarte_helpers/bytes-buf", "yarte_derive/bytes-buf"]
[dependencies]
yarte_derive = { workspace = true }
yarte_helpers = { workspace = true }
-buf-min = { version = "0.7", optional = true }
+buf-min = { workspace = true, optional = true }
[dev-dependencies]
trybuild = { version = "1.0", features = ["diff"] }
diff --git a/yarte_derive/src/lib.rs b/yarte_derive/src/lib.rs
index 7de73416..f706b335 100644
--- a/yarte_derive/src/lib.rs
+++ b/yarte_derive/src/lib.rs
@@ -375,7 +375,7 @@ pub fn ywrite_min(i: TokenStream) -> TokenStream {
struct TemplateArg {
pub s: syn::LitStr,
_d: Option,
- _c: Option
+ _c: Option,
}
impl syn::parse::Parse for TemplateArg {
@@ -383,7 +383,7 @@ impl syn::parse::Parse for TemplateArg {
Ok(TemplateArg {
s: input.parse()?,
_d: input.parse()?,
- _c: input.parse()?
+ _c: input.parse()?,
})
}
}
diff --git a/yarte_helpers/Cargo.toml b/yarte_helpers/Cargo.toml
index 2e939156..8408034d 100644
--- a/yarte_helpers/Cargo.toml
+++ b/yarte_helpers/Cargo.toml
@@ -42,7 +42,7 @@ serde = { version = "1.0", features = ["derive"] }
toml = { version = "0.7" }
serde_json = { version = "1.0", optional = true }
-buf-min = { version = "0.7", optional = true}
+buf-min = { workspace = true, optional = true}
uuid = { version = "1.3", optional = true }