Skip to content

Commit

Permalink
fix: clean and prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
zzau13 committed Jul 29, 2023
1 parent 616daf3 commit fa72fff
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 304 deletions.
26 changes: 15 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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" }
8 changes: 3 additions & 5 deletions examples/bytes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
55 changes: 11 additions & 44 deletions examples/bytes/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 }}";

Expand All @@ -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);
}
8 changes: 0 additions & 8 deletions examples/bytes/templates/base.hbs

This file was deleted.

16 changes: 0 additions & 16 deletions examples/bytes/templates/deep/more/card/form.hbs

This file was deleted.

8 changes: 0 additions & 8 deletions examples/bytes/templates/deep/more/card/hi.hbs

This file was deleted.

11 changes: 0 additions & 11 deletions examples/bytes/templates/deep/more/deep/welcome.hbs

This file was deleted.

7 changes: 0 additions & 7 deletions examples/bytes/templates/deep/more/doc/head.hbs

This file was deleted.

1 change: 0 additions & 1 deletion examples/bytes/templates/deep/more/doc/t.hbs

This file was deleted.

7 changes: 0 additions & 7 deletions examples/bytes/templates/index.hbs

This file was deleted.

15 changes: 0 additions & 15 deletions examples/simple/Cargo.toml

This file was deleted.

6 changes: 0 additions & 6 deletions examples/simple/build.rs

This file was deleted.

79 changes: 0 additions & 79 deletions examples/simple/src/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions examples/simple/templates/base.hbs

This file was deleted.

16 changes: 0 additions & 16 deletions examples/simple/templates/deep/more/card/form.hbs

This file was deleted.

8 changes: 0 additions & 8 deletions examples/simple/templates/deep/more/card/hi.hbs

This file was deleted.

11 changes: 0 additions & 11 deletions examples/simple/templates/deep/more/deep/welcome.hbs

This file was deleted.

7 changes: 0 additions & 7 deletions examples/simple/templates/deep/more/doc/head.hbs

This file was deleted.

1 change: 0 additions & 1 deletion examples/simple/templates/deep/more/doc/t.hbs

This file was deleted.

6 changes: 0 additions & 6 deletions examples/simple/templates/hello.hbs

This file was deleted.

7 changes: 0 additions & 7 deletions examples/simple/templates/index.hbs

This file was deleted.

18 changes: 0 additions & 18 deletions examples/simple/yarte.toml

This file was deleted.

2 changes: 1 addition & 1 deletion yarte/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
Loading

0 comments on commit fa72fff

Please sign in to comment.