diff --git a/Cargo.lock b/Cargo.lock index 014b5425..978a7f74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -855,6 +855,35 @@ dependencies = [ "serde_json", ] +[[package]] +name = "actix-web-lab" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cd7a15518fb68eb657abc5b6b16c387f99b6db7f549f4884c72d05165139b8" +dependencies = [ + "actix-files 0.6.0-beta.16", + "actix-http 3.0.0-rc.3", + "actix-service 2.0.2", + "actix-utils 3.0.0", + "actix-web 4.0.0-rc.3", + "bytes 1.1.0", + "csv", + "derive_more", + "digest 0.10.3", + "futures-core", + "futures-util", + "hmac 0.12.1", + "local-channel", + "log", + "mime", + "once_cell", + "pin-project-lite 0.2.8", + "serde 1.0.136", + "serde_json", + "serde_urlencoded", + "tokio 1.17.0", +] + [[package]] name = "actix_derive" version = "0.5.0" @@ -1546,7 +1575,10 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ + "lazy_static", "memchr", + "regex-automata", + "serde 1.0.136", ] [[package]] @@ -2037,6 +2069,28 @@ dependencies = [ "subtle", ] +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa 0.4.8", + "ryu", + "serde 1.0.136", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + [[package]] name = "ctr" version = "0.8.0" @@ -2422,6 +2476,18 @@ dependencies = [ "instant", ] +[[package]] +name = "filetime" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + [[package]] name = "firestorm" version = "0.5.0" @@ -2867,6 +2933,15 @@ dependencies = [ "digest 0.10.3", ] +[[package]] +name = "home" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "hostname" version = "0.3.1" @@ -3162,6 +3237,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +[[package]] +name = "itoap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" + [[package]] name = "jobserver" version = "0.1.24" @@ -4744,6 +4825,12 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-syntax" version = "0.6.25" @@ -5120,6 +5207,43 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +[[package]] +name = "sailfish" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f030905cfc5f869b6784dc4e5c83a20d1f77c92bae1a0d158baf9404100c3e" +dependencies = [ + "itoap", + "ryu", + "sailfish-macros", + "version_check 0.9.4", +] + +[[package]] +name = "sailfish-compiler" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7a8620f80b37af2e55153ee142bfdb8085f30c454be453e922466d483b0d184" +dependencies = [ + "filetime", + "home", + "memchr", + "proc-macro2", + "quote", + "syn", + "yaml-rust", +] + +[[package]] +name = "sailfish-macros" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b31ded532bded4637d49297e3247476ebc266efab4b054dc48037fa88846fdeb" +dependencies = [ + "proc-macro2", + "sailfish-compiler", +] + [[package]] name = "same-file" version = "1.0.6" @@ -5876,6 +6000,17 @@ dependencies = [ "serde_json", ] +[[package]] +name = "template_sailfish" +version = "0.1.0" +dependencies = [ + "actix-web 4.0.0-rc.3", + "actix-web-lab", + "env_logger 0.9.0", + "log", + "sailfish", +] + [[package]] name = "template_yarte" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index b14e25ef..db90ab60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ members = [ "template_engines/tera", "template_engines/tinytemplate", "template_engines/yarte", + "template_engines/sailfish", "websockets/autobahn", "websockets/chat-broker", "websockets/chat", diff --git a/template_engines/handlebars/README.md b/template_engines/handlebars/README.md index e7061a60..78bac4bd 100644 --- a/template_engines/handlebars/README.md +++ b/template_engines/handlebars/README.md @@ -1,12 +1,16 @@ # Handlebars -This is an example of how to use Actix Web with the [Handlebars templating language](https://crates.io/crates/handlebars), which is currently the most popular crate that achieves this. After starting the server with `cargo run`, you may visit the following pages: +This is an example of how to use Actix Web with the [Handlebars](https://crates.io/crates/handlebars) templating language, which is currently the most popular crate that achieves this. + +## Usage ```bash cd template_engines/handlebars cargo run ``` +After starting the server, you may visit the following pages: + - http://localhost:8080 - http://localhost:8080/Emma/documents - http://localhost:8080/Bob/passwords diff --git a/template_engines/handlebars/static/templates/index.html b/template_engines/handlebars/static/templates/index.html index 867c114e..013026cb 100644 --- a/template_engines/handlebars/static/templates/index.html +++ b/template_engines/handlebars/static/templates/index.html @@ -9,4 +9,4 @@
This is an example of how to use {{name}} with Actix-Web.