diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8ea3298..24f02d5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -69,16 +69,8 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.66 - - uses: dtolnay/rust-toolchain@1.60 - - name: Check (no filters, no syntax) - run: cargo check --no-default-features --features serde,unicode - - - uses: dtolnay/rust-toolchain@1.61 - - name: Check (no filters) - run: cargo check --no-default-features --features serde,syntax,unicode - - - uses: dtolnay/rust-toolchain@1.65 - name: Test run: cargo test --all-features env: diff --git a/Cargo.lock b/Cargo.lock index 30c6ea2..0690f4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,9 +52,9 @@ checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" [[package]] name = "arbitrary" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e1373abdaa212b704512ec2bd8b26bd0b7d5c3f70117411a5d9a451383c859" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" dependencies = [ "derive_arbitrary", ] @@ -82,12 +82,6 @@ dependencies = [ "upon 0.8.1", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.3.3" @@ -143,21 +137,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "winapi", + "windows-targets 0.52.6", ] [[package]] name = "chrono-tz" -version = "0.8.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1369bc6b9e9a7dfdae2055f6ec151fe9c554a9d23d357c0237cee2e25eaabb7" +checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" dependencies = [ "chrono", "chrono-tz-build", @@ -166,9 +160,9 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f5ebdc942f57ed96d560a6d1a459bae5851102a25d5bf89dc04ae453e31ecf" +checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" dependencies = [ "parse-zoneinfo", "phf", @@ -254,7 +248,7 @@ dependencies = [ "clap", "criterion-plot", "is-terminal", - "itertools", + "itertools 0.10.5", "num-traits", "once_cell", "oorandom", @@ -275,7 +269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -331,6 +325,41 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "deranged" version = "0.3.11" @@ -342,15 +371,46 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.1" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" dependencies = [ + "darling", "proc-macro2", "quote", "syn", ] +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn", +] + [[package]] name = "deunicode" version = "0.4.5" @@ -390,9 +450,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "errno" @@ -436,7 +496,7 @@ name = "gen-filters" version = "0.0.0" dependencies = [ "either", - "itertools", + "itertools 0.14.0", ] [[package]] @@ -475,28 +535,28 @@ dependencies = [ [[package]] name = "globwalk" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" dependencies = [ - "bitflags 1.3.2", + "bitflags", "ignore", "walkdir", ] [[package]] name = "goldie" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1d4b95ae93c6d91591a2998aa7363113e51130ede293b3c92ac89b63e13914" +checksum = "aa70c42797cac60e6182e00f33f629212e02ba80d67e8a976f6168b57568d78e" dependencies = [ "anyhow", "once_cell", "pretty_assertions", "serde", "serde_json", - "upon 0.5.0", - "yansi", + "upon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "yansi 1.0.1", ] [[package]] @@ -507,16 +567,18 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.4.0" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" +checksum = "3d6b224b95c1e668ac0270325ad563b2eef1469fbbb8959bc7c692c844b813d9" dependencies = [ + "derive_builder", "log", + "num-order", "pest", "pest_derive", "serde", "serde_json", - "thiserror", + "thiserror 2.0.11", ] [[package]] @@ -557,6 +619,12 @@ dependencies = [ "cc", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "ignore" version = "0.4.20" @@ -594,6 +662,24 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -642,13 +728,12 @@ checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libfuzzer-sys" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +checksum = "9b9569d2f74e257076d8c6bfa73fb505b46b851e51ddaecc825944aa3bed17fa" dependencies = [ "arbitrary", "cc", - "once_cell", ] [[package]] @@ -665,9 +750,9 @@ checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "liquid" -version = "0.26.4" +version = "0.26.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69f68ae1011499ae2ef879f631891f21c78e309755f4a5e483c4a8f12e10b609" +checksum = "7cdcc72b82748f47c2933c172313f5a9aea5b2c4eb3fa4c66b4ea55bb60bb4b1" dependencies = [ "doc-comment", "liquid-core", @@ -678,12 +763,12 @@ dependencies = [ [[package]] name = "liquid-core" -version = "0.26.4" +version = "0.26.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e0724dfcaad5cfb7965ea0f178ca0870b8d7315178f4a7179f5696f7f04d5f" +checksum = "2752e978ffc53670f3f2e8b3ef09f348d6f7b5474a3be3f8a5befe5382e4effb" dependencies = [ "anymap2", - "itertools", + "itertools 0.13.0", "kstring", "liquid-derive", "num-traits", @@ -696,9 +781,9 @@ dependencies = [ [[package]] name = "liquid-derive" -version = "0.26.4" +version = "0.26.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2fb41a9bb4257a3803154bdf7e2df7d45197d1941c9b1a90ad815231630721" +checksum = "3b51f1d220e3fa869e24cfd75915efe3164bd09bb11b3165db3f37f57bf673e3" dependencies = [ "proc-macro2", "quote", @@ -707,11 +792,11 @@ dependencies = [ [[package]] name = "liquid-lib" -version = "0.26.4" +version = "0.26.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a17e273a6fb1fb6268f7a5867ddfd0bd4683c7e19b51084f3d567fad4348c0" +checksum = "59b1a298d3d2287ee5b1e43840d885b8fdfc37d3f4e90d82aacfd04d021618da" dependencies = [ - "itertools", + "itertools 0.13.0", "liquid-core", "once_cell", "percent-encoding", @@ -743,9 +828,9 @@ dependencies = [ [[package]] name = "minijinja" -version = "1.0.9" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f98b09920c8be9ff96a5625aca5b5db7a4f4ba025132ff7d7aacb72c0244a45" +checksum = "212b4cab3aad057bc6e611814472905546c533295723b9e26a31c7feb19a8e65" dependencies = [ "aho-corasick", "serde", @@ -757,6 +842,21 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-modular" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f" + +[[package]] +name = "num-order" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" +dependencies = [ + "num-modular", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -809,7 +909,7 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d2d1d55045829d65aad9d389139882ad623b33b904e7c9f1b10c5b8927298e5" dependencies = [ - "thiserror", + "thiserror 1.0.50", "ucd-trie", ] @@ -932,23 +1032,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ "diff", - "yansi", + "yansi 0.5.1", ] [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1040,7 +1140,7 @@ version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" dependencies = [ - "bitflags 2.3.3", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -1070,18 +1170,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.190" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -1090,11 +1190,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1131,11 +1232,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "syn" -version = "2.0.38" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -1144,9 +1251,9 @@ dependencies = [ [[package]] name = "tera" -version = "1.19.1" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970dff17c11e884a4a09bc76e3a17ef71e01bb13447a11e85226e254fe6d10b8" +checksum = "ab9d851b45e865f178319da0abdbfe6acbc4328759ff18dafc3a41c16b4cd2ee" dependencies = [ "chrono", "chrono-tz", @@ -1170,7 +1277,16 @@ version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.50", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -1184,6 +1300,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.1.7" @@ -1316,24 +1443,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] -name = "upon" -version = "0.5.0" +name = "unicode-width" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77ce40602cb1a7dfcdd6336f6d8baa2803c898aafbc0d46156b59727f2e7135" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "upon" +version = "0.8.1" dependencies = [ + "aho-corasick", "serde", "unicode-ident", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] name = "upon" version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fe29601d1624f104fa9a35ea71a5f523dd8bd1cfc8c31f8124ad2b829f013c0" dependencies = [ - "aho-corasick", "serde", "unicode-ident", - "unicode-width", + "unicode-width 0.1.11", ] [[package]] @@ -1459,7 +1592,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1468,7 +1601,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1477,13 +1610,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1492,44 +1641,98 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" diff --git a/Cargo.toml b/Cargo.toml index 7e6e7c4..5be1742 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "upon" version = "0.8.1" authors = ["Ross MacArthur "] edition = "2021" -rust-version = "1.60" +rust-version = "1.66" description = "A simple, powerful template engine with minimal dependencies and configurable delimiters" readme = "README.md" repository = "https://github.com/rossmacarthur/upon" @@ -19,7 +19,7 @@ rustdoc-args = ["--cfg", "docsrs"] aho-corasick = { version = "1.1.2", optional = true } serde = { version = "1.0.137", optional = true } unicode-ident = { version = "1.0.5", optional = true } -unicode-width = { version = "0.1.9", optional = true } +unicode-width = { version = "0.2.0", optional = true } [dev-dependencies] serde = { version = "1.0.137", features = ["derive"] } diff --git a/README.md b/README.md index e4f5d4d..dfb3cb5 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,8 @@ inspired by template engines like [Liquid] and [Jinja]. ### MSRV -Currently the minimum supported version for `upon` is Rust 1.65. Disabling -the **`filters`** feature reduces it to Rust 1.60. The MSRV will only ever -be increased in a breaking release. +Currently the minimum supported version for `upon` is Rust 1.66. The MSRV +will only ever be increased in a breaking release. ## Getting started @@ -131,8 +130,8 @@ The following crate features are available. construct the context using [`Value`][value]’s `From` impls. - **`syntax`** *(disabled by default)* — Enables support for configuring - custom delimiters in templates (see `Engine::with_syntax`) and pulls in - the `aho-corasick` crate. + custom delimiters in templates (see [`Engine::with_syntax`][enginewith_syntax]) and pulls in + the [`aho-corasick`][aho-corasick] crate. - **`unicode`** *(enabled by default)* — Enables unicode support and pulls in the [`unicode-ident`][unicode-ident] and @@ -273,10 +272,12 @@ at your option. [add_template]: https://docs.rs/upon/latest/upon/struct.Engine.html#method.add_template +[aho-corasick]: https://crates.io/crates/aho-corasick [compile]: https://docs.rs/upon/latest/upon/struct.Engine.html#method.compile [engine]: https://docs.rs/upon/latest/upon/struct.Engine.html [engineadd_filter]: https://docs.rs/upon/latest/upon/struct.Engine.html#method.add_filter [engineadd_formatter]: https://docs.rs/upon/latest/upon/struct.Engine.html#method.add_formatter +[enginewith_syntax]: https://docs.rs/upon/latest/upon/struct.Engine.html#method.with_syntax [filters]: https://docs.rs/upon/latest/upon/filters/index.html [fmt]: https://docs.rs/upon/latest/upon/fmt/index.html [render]: https://docs.rs/upon/latest/upon/struct.TemplateRef.html#method.render diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 396fc3e..75e33d5 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -5,19 +5,19 @@ edition = "2021" publish = false [dependencies] -handlebars = "4.3.7" -liquid = "0.26.4" -minijinja = { version = "1.0.5", features = ["custom_syntax"] } +handlebars = "6.3.0" +liquid = "0.26.9" +minijinja = { version = "2.6.0", features = ["custom_syntax"] } rand = "0.8.5" serde = { version = "1.0.137", features = ["derive"] } -serde_json = "1.0.103" -tera = "1.19.0" +serde_json = "1.0.135" +tera = "1.20.0" tinytemplate = "1.2.1" upon = { path = "..", features = ["syntax"] } [dev-dependencies] criterion = { version = "0.5.1", features = ["html_reports"] } -goldie = "0.4.3" +goldie = "0.5.0" [[bench]] name = "engines" diff --git a/benches/benchdata/basic/minijinja.html b/benches/benchdata/basic/jinja.html similarity index 100% rename from benches/benchdata/basic/minijinja.html rename to benches/benchdata/basic/jinja.html diff --git a/benches/benchdata/basic/tera.html b/benches/benchdata/basic/tera.html deleted file mode 100644 index 5fa58ef..0000000 --- a/benches/benchdata/basic/tera.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - {{ title }} - - - - - - - - {%- for user in users -%} - {% if not user.is_disabled %} - {# This is a comment #} - - - - - {% endif %} - {%- endfor -%} -
NameAge
{{ user.name }}{{ user.age }}
- - diff --git a/benches/benchdata/basic/upon.html b/benches/benchdata/basic/upon.html deleted file mode 100644 index 5fa58ef..0000000 --- a/benches/benchdata/basic/upon.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - {{ title }} - - - - - - - - {%- for user in users -%} - {% if not user.is_disabled %} - {# This is a comment #} - - - - - {% endif %} - {%- endfor -%} -
NameAge
{{ user.name }}{{ user.age }}
- - diff --git a/benches/benchdata/filters/handlebars.html b/benches/benchdata/filters/handlebars.html index 56697f5..35bdae1 100644 --- a/benches/benchdata/filters/handlebars.html +++ b/benches/benchdata/filters/handlebars.html @@ -1,3 +1,3 @@ -{{~ #each users as |user| ~}} +{{ #each users as |user| }} {{ reverse (lower user.name) }} -{{~ /each ~}} +{{ /each }} diff --git a/benches/benchdata/filters/minijinja.html b/benches/benchdata/filters/jinja.html similarity index 100% rename from benches/benchdata/filters/minijinja.html rename to benches/benchdata/filters/jinja.html diff --git a/benches/benchdata/filters/tera.html b/benches/benchdata/filters/tera.html deleted file mode 100644 index 376157d..0000000 --- a/benches/benchdata/filters/tera.html +++ /dev/null @@ -1,3 +0,0 @@ -{% for user in users %} - {{ user.name | lower | reverse }} -{% endfor %} diff --git a/benches/benchdata/filters/upon.html b/benches/benchdata/filters/upon.html deleted file mode 100644 index 376157d..0000000 --- a/benches/benchdata/filters/upon.html +++ /dev/null @@ -1,3 +0,0 @@ -{% for user in users %} - {{ user.name | lower | reverse }} -{% endfor %} diff --git a/benches/benchdata/literals/minijinja.html b/benches/benchdata/literals/minijinja.html new file mode 100644 index 0000000..29da2a1 --- /dev/null +++ b/benches/benchdata/literals/minijinja.html @@ -0,0 +1,104 @@ +{% for user in [ + { "name": "Margaret Brewer" }, + { "name": "Cruz McCarty" }, + { "name": "Halo Rollins" }, + { "name": "Wes Velazquez" }, + { "name": "Jaliyah Ford" }, + { "name": "Luis Mullen" }, + { "name": "Shay Navarro" }, + { "name": "Reid Glass" }, + { "name": "Clare Collins" }, + { "name": "Miles Christensen" }, + { "name": "Carmen Solomon" }, + { "name": "Musa Steele" }, + { "name": "Rylie Dunlap" }, + { "name": "Aries Miranda" }, + { "name": "Amina Davenport" }, + { "name": "Dariel Medrano" }, + { "name": "Halle Glenn" }, + { "name": "Zaid Hahn" }, + { "name": "Fallon Wyatt" }, + { "name": "Sam Tanner" }, + { "name": "Harmoni McBride" }, + { "name": "Denver Campos" }, + { "name": "Sutton Choi" }, + { "name": "Khari Medina" }, + { "name": "Elliana Sweeney" }, + { "name": "Nixon Andrews" }, + { "name": "Payton Bautista" }, + { "name": "Raul Callahan" }, + { "name": "Kimber Lyons" }, + { "name": "Cyrus Hodge" }, + { "name": "Coraline Santos" }, + { "name": "Walker Navarro" }, + { "name": "Winter Ferguson" }, + { "name": "Miguel Garza" }, + { "name": "River Hartman" }, + { "name": "Baker Aguilar" }, + { "name": "Josie Cook" }, + { "name": "Ezekiel Sawyer" }, + { "name": "Marina Schmidt" }, + { "name": "Zayden Russell" }, + { "name": "Raelynn Mendez" }, + { "name": "Arthur Bates" }, + { "name": "Madilyn Medina" }, + { "name": "George Rangel" }, + { "name": "Gloria Henson" }, + { "name": "Bellamy Raymond" }, + { "name": "Hadlee Case" }, + { "name": "Bentlee Kramer" }, + { "name": "Hanna Holland" }, + { "name": "Brady Douglas" }, + { "name": "Aniyah Duffy" }, + { "name": "Kyng Morton" }, + { "name": "Mallory Green" }, + { "name": "Anthony Chandler" }, + { "name": "Viviana Shepard" }, + { "name": "Damari McCann" }, + { "name": "Joyce George" }, + { "name": "Mark Reynolds" }, + { "name": "Isabelle Andrews" }, + { "name": "Lukas Archer" }, + { "name": "Kadence Cardenas" }, + { "name": "Johnathan Vazquez" }, + { "name": "Journee Cohen" }, + { "name": "Killian Orozco" }, + { "name": "Renata Vega" }, + { "name": "Aidan Phillips" }, + { "name": "Naomi Evans" }, + { "name": "Elias Spence" }, + { "name": "Aislinn Strickland" }, + { "name": "Keegan Cline" }, + { "name": "Lina Trejo" }, + { "name": "Wesson Hale" }, + { "name": "Brinley Cabrera" }, + { "name": "Cade Ibarra" }, + { "name": "Madilynn Nunez" }, + { "name": "Caden Sharp" }, + { "name": "Camryn Hoffman" }, + { "name": "Steven Young" }, + { "name": "Zoey Gross" }, + { "name": "Quinn Allison" }, + { "name": "Chelsea Terrell" }, + { "name": "Jaxen Russell" }, + { "name": "Raelynn Payne" }, + { "name": "Edward Gillespie" }, + { "name": "Alianna Bernal" }, + { "name": "Eithan Lane" }, + { "name": "Amy Turner" }, + { "name": "Joshua Hester" }, + { "name": "Zendaya Camacho" }, + { "name": "Tatum Williamson" }, + { "name": "Catherine Kaur" }, + { "name": "Augustine Hunt" }, + { "name": "Genevieve Villanueva" }, + { "name": "Huxley Sweeney" }, + { "name": "Yara Barajas" }, + { "name": "Brennan Carrillo" }, + { "name": "Kaylani Ingram" }, + { "name": "Tripp Palmer" }, + { "name": "Juniper Schroeder" }, + { "name": "Izaiah Schultz" }, +] %} + {{ user.name }} +{% endfor %} diff --git a/benches/benchdata/literals/upon.html b/benches/benchdata/literals/upon.html new file mode 100644 index 0000000..604b7f6 --- /dev/null +++ b/benches/benchdata/literals/upon.html @@ -0,0 +1,104 @@ +{% for user in [ + { name: "Margaret Brewer" }, + { name: "Cruz McCarty" }, + { name: "Halo Rollins" }, + { name: "Wes Velazquez" }, + { name: "Jaliyah Ford" }, + { name: "Luis Mullen" }, + { name: "Shay Navarro" }, + { name: "Reid Glass" }, + { name: "Clare Collins" }, + { name: "Miles Christensen" }, + { name: "Carmen Solomon" }, + { name: "Musa Steele" }, + { name: "Rylie Dunlap" }, + { name: "Aries Miranda" }, + { name: "Amina Davenport" }, + { name: "Dariel Medrano" }, + { name: "Halle Glenn" }, + { name: "Zaid Hahn" }, + { name: "Fallon Wyatt" }, + { name: "Sam Tanner" }, + { name: "Harmoni McBride" }, + { name: "Denver Campos" }, + { name: "Sutton Choi" }, + { name: "Khari Medina" }, + { name: "Elliana Sweeney" }, + { name: "Nixon Andrews" }, + { name: "Payton Bautista" }, + { name: "Raul Callahan" }, + { name: "Kimber Lyons" }, + { name: "Cyrus Hodge" }, + { name: "Coraline Santos" }, + { name: "Walker Navarro" }, + { name: "Winter Ferguson" }, + { name: "Miguel Garza" }, + { name: "River Hartman" }, + { name: "Baker Aguilar" }, + { name: "Josie Cook" }, + { name: "Ezekiel Sawyer" }, + { name: "Marina Schmidt" }, + { name: "Zayden Russell" }, + { name: "Raelynn Mendez" }, + { name: "Arthur Bates" }, + { name: "Madilyn Medina" }, + { name: "George Rangel" }, + { name: "Gloria Henson" }, + { name: "Bellamy Raymond" }, + { name: "Hadlee Case" }, + { name: "Bentlee Kramer" }, + { name: "Hanna Holland" }, + { name: "Brady Douglas" }, + { name: "Aniyah Duffy" }, + { name: "Kyng Morton" }, + { name: "Mallory Green" }, + { name: "Anthony Chandler" }, + { name: "Viviana Shepard" }, + { name: "Damari McCann" }, + { name: "Joyce George" }, + { name: "Mark Reynolds" }, + { name: "Isabelle Andrews" }, + { name: "Lukas Archer" }, + { name: "Kadence Cardenas" }, + { name: "Johnathan Vazquez" }, + { name: "Journee Cohen" }, + { name: "Killian Orozco" }, + { name: "Renata Vega" }, + { name: "Aidan Phillips" }, + { name: "Naomi Evans" }, + { name: "Elias Spence" }, + { name: "Aislinn Strickland" }, + { name: "Keegan Cline" }, + { name: "Lina Trejo" }, + { name: "Wesson Hale" }, + { name: "Brinley Cabrera" }, + { name: "Cade Ibarra" }, + { name: "Madilynn Nunez" }, + { name: "Caden Sharp" }, + { name: "Camryn Hoffman" }, + { name: "Steven Young" }, + { name: "Zoey Gross" }, + { name: "Quinn Allison" }, + { name: "Chelsea Terrell" }, + { name: "Jaxen Russell" }, + { name: "Raelynn Payne" }, + { name: "Edward Gillespie" }, + { name: "Alianna Bernal" }, + { name: "Eithan Lane" }, + { name: "Amy Turner" }, + { name: "Joshua Hester" }, + { name: "Zendaya Camacho" }, + { name: "Tatum Williamson" }, + { name: "Catherine Kaur" }, + { name: "Augustine Hunt" }, + { name: "Genevieve Villanueva" }, + { name: "Huxley Sweeney" }, + { name: "Yara Barajas" }, + { name: "Brennan Carrillo" }, + { name: "Kaylani Ingram" }, + { name: "Tripp Palmer" }, + { name: "Juniper Schroeder" }, + { name: "Izaiah Schultz" }, +] %} + {{ user.name }} +{% endfor %} diff --git a/benches/benchdata/syntax/minijinja.html b/benches/benchdata/syntax/jinja.html similarity index 100% rename from benches/benchdata/syntax/minijinja.html rename to benches/benchdata/syntax/jinja.html diff --git a/benches/benchdata/syntax/upon.html b/benches/benchdata/syntax/upon.html deleted file mode 100644 index d234a79..0000000 --- a/benches/benchdata/syntax/upon.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - { title } - - - - - - - - <%- for user in users -%> - <% if not user.is_disabled %> - <# This is a comment #> - - - - - <% endif %> - <%- endfor -%> -
NameAge
{ user.name }{ user.age }
- - diff --git a/benches/benches/engines.rs b/benches/benches/engines.rs index c336e16..6f4e804 100644 --- a/benches/benches/engines.rs +++ b/benches/benches/engines.rs @@ -11,9 +11,7 @@ criterion_group! { benches, bench_init, bench_compile, - bench_syntax, bench_render, - bench_filters, } /// Benchmarks the time taken to create a new instance of the engine. @@ -38,34 +36,20 @@ pub fn bench_init(c: &mut Criterion) { /// Benchmarks the time taken to compile a template. pub fn bench_compile(c: &mut Criterion) { - let mut g = c.benchmark_group("compile"); - macro_rules! bench { - ($E:ty, $source:literal) => {{ - g.bench_function(<$E as Engine>::name(), |b| { - let source = repeat(include_str!($source), 50); + ($g:ident, $E:ty, $source:literal) => {{ + $g.bench_function(<$E as Engine>::name(), |b| { + let source = repeat(include_str!(concat!("../benchdata/", $source)), 50); let mut engine = <$E as Engine>::new(); b.iter(|| engine.add_template("bench", &source)); }); }}; } - bench!(Handlebars, "../benchdata/basic/handlebars.html"); - bench!(Liquid, "../benchdata/basic/liquid.html"); - bench!(Minijinja, "../benchdata/basic/minijinja.html"); - bench!(Tera, "../benchdata/basic/tera.html"); - bench!(TinyTemplate, "../benchdata/basic/tinytemplate.html"); - bench!(Upon, "../benchdata/basic/upon.html"); -} - -/// Benchmarks the time taken to compile a template with custom syntax. -pub fn bench_syntax(c: &mut Criterion) { - let mut g = c.benchmark_group("syntax"); - - macro_rules! bench { - ($E:ty, $source:literal) => {{ - g.bench_function(<$E as Engine>::name(), |b| { - let source = repeat(include_str!($source), 50); + macro_rules! bench_with_syntax { + ($g:ident, $E:ty, $source:literal) => {{ + $g.bench_function(<$E as Engine>::name(), |b| { + let source = repeat(include_str!(concat!("../benchdata/", $source)), 50); let mut engine = <$E as Engine>::with_syntax(("{", "}"), ("<%", "%>"), ("<#", "#>")); b.iter(|| engine.add_template("bench", &source)); @@ -73,20 +57,38 @@ pub fn bench_syntax(c: &mut Criterion) { }}; } - bench!(Minijinja, "../benchdata/syntax/minijinja.html"); - bench!(Upon, "../benchdata/syntax/upon.html"); + { + let mut g = c.benchmark_group("compile/basic"); + // 8 times slower than the next slowest, leave out so the chart looks reasonable: + // bench!(g, Handlebars, "basic/handlebars.html"); + bench!(g, Liquid, "basic/liquid.html"); + bench!(g, Minijinja, "basic/jinja.html"); + bench!(g, Tera, "basic/jinja.html"); + bench!(g, TinyTemplate, "basic/tinytemplate.html"); + bench!(g, Upon, "basic/jinja.html"); + } + + { + let mut g = c.benchmark_group("compile/syntax"); + bench_with_syntax!(g, Minijinja, "syntax/jinja.html"); + bench_with_syntax!(g, Upon, "syntax/jinja.html"); + } + + { + let mut g = c.benchmark_group("compile/literals"); + bench!(g, Minijinja, "literals/minijinja.html"); + bench!(g, Upon, "literals/upon.html"); + } } /// Benchmarks the time taken to render a template as a string. pub fn bench_render(c: &mut Criterion) { - let mut g = c.benchmark_group("render"); - let ctx = context::random(150); macro_rules! bench { - ($E:ty, $source:literal) => {{ - g.bench_function(<$E as Engine>::name(), |b| { - let source = repeat(include_str!($source), 20); + ($g:ident, $E:ty, $source:literal) => {{ + $g.bench_function(<$E as Engine>::name(), |b| { + let source = repeat(include_str!(concat!("../benchdata/", $source)), 50); let mut engine = <$E as Engine>::new(); <$E as Engine>::add_template(&mut engine, "bench", &source); b.iter(|| <$E as Engine>::render(&engine, "bench", &ctx)); @@ -94,36 +96,23 @@ pub fn bench_render(c: &mut Criterion) { }}; } - bench!(Handlebars, "../benchdata/basic/handlebars.html"); - bench!(Liquid, "../benchdata/basic/liquid.html"); - bench!(Minijinja, "../benchdata/basic/minijinja.html"); - bench!(Tera, "../benchdata/basic/tera.html"); - bench!(TinyTemplate, "../benchdata/basic/tinytemplate.html"); - bench!(Upon, "../benchdata/basic/upon.html"); -} - -/// Benchmarks the time taken to transform a string with multiple filters. -fn bench_filters(c: &mut Criterion) { - let mut g = c.benchmark_group("filters"); - - let ctx = context::random(250); - - macro_rules! bench { - ($E:ty, $source:literal) => {{ - g.bench_function(<$E as Engine>::name(), |b| { - let source = repeat(include_str!($source), 10); - let mut engine = <$E as Engine>::new(); - <$E as Engine>::add_filters(&mut engine); - <$E as Engine>::add_template(&mut engine, "bench", &source); - b.iter(|| <$E as Engine>::render(&engine, "bench", &ctx)); - }); - }}; + { + let mut g = c.benchmark_group("render/basic"); + bench!(g, Handlebars, "basic/handlebars.html"); + bench!(g, Liquid, "basic/liquid.html"); + bench!(g, Minijinja, "basic/jinja.html"); + bench!(g, Tera, "basic/jinja.html"); + bench!(g, TinyTemplate, "basic/tinytemplate.html"); + bench!(g, Upon, "basic/jinja.html"); } - bench!(Handlebars, "../benchdata/filters/handlebars.html"); - bench!(Minijinja, "../benchdata/filters/minijinja.html"); - bench!(Tera, "../benchdata/filters/tera.html"); - bench!(Upon, "../benchdata/filters/upon.html"); + { + let mut g = c.benchmark_group("render/filters"); + bench!(g, Handlebars, "filters/handlebars.html"); + bench!(g, Minijinja, "filters/jinja.html"); + bench!(g, Tera, "filters/jinja.html"); + bench!(g, Upon, "filters/jinja.html"); + } } fn repeat(source: &str, n: usize) -> String { diff --git a/benches/src/lib.rs b/benches/src/lib.rs index 1e125f1..1b69787 100644 --- a/benches/src/lib.rs +++ b/benches/src/lib.rs @@ -15,9 +15,6 @@ pub trait Engine<'a>: Sized { ) -> Self { unimplemented!() } - fn add_filters(&mut self) { - unimplemented!() - } fn add_template(&mut self, name: &'static str, source: &'a str); fn render(&self, name: &'static str, ctx: &S) -> String where @@ -41,20 +38,16 @@ impl<'engine> Engine<'engine> for Handlebars<'engine> { #[inline] fn new() -> Self { let mut hbs = handlebars::Handlebars::new(); + handlebars_helper!(lower: |s: String| s.to_lowercase()); + handlebars_helper!(reverse: |s: String| String::from_iter(s.chars().rev())); + hbs.register_helper("lower", Box::new(lower)); + hbs.register_helper("reverse", Box::new(reverse)); // handlebars escapes HTML by default, so lets add a default formatter // to make the benchmark a bit fairer. hbs.register_escape_fn(handlebars::no_escape); hbs } - #[inline] - fn add_filters(&mut self) { - handlebars_helper!(lower: |s: String| s.to_lowercase()); - handlebars_helper!(reverse: |s: String| String::from_iter(s.chars().rev())); - self.register_helper("lower", Box::new(lower)); - self.register_helper("reverse", Box::new(reverse)); - } - #[inline] fn add_template(&mut self, name: &'static str, source: &'engine str) { self.register_template_string(name, source).unwrap(); @@ -135,20 +128,17 @@ impl<'engine> Engine<'engine> for Minijinja<'engine> { (comment_start, comment_end): (&'static str, &'static str), ) -> Self { let mut env = minijinja::Environment::new(); - env.set_syntax(minijinja::Syntax { - block_start: block_start.into(), - block_end: block_end.into(), - variable_start: variable_start.into(), - variable_end: variable_end.into(), - comment_start: comment_start.into(), - comment_end: comment_end.into(), - }) - .unwrap(); + env.set_syntax( + minijinja::syntax::SyntaxConfig::builder() + .block_delimiters(block_start, block_end) + .variable_delimiters(variable_start, variable_end) + .comment_delimiters(comment_start, comment_end) + .build() + .unwrap(), + ); env } - fn add_filters(&mut self) {} - #[inline] fn add_template(&mut self, name: &'static str, source: &'engine str) { self.add_template(name, source).unwrap(); @@ -180,9 +170,6 @@ impl<'engine> Engine<'engine> for Tera { tera::Tera::default() } - #[inline] - fn add_filters(&mut self) {} - #[inline] fn add_template(&mut self, name: &'static str, source: &'engine str) { self.add_raw_template(name, source).unwrap(); @@ -247,7 +234,10 @@ impl<'engine> Engine<'engine> for upon::Engine<'engine> { #[inline] fn new() -> Self { - upon::Engine::new() + let mut engine = upon::Engine::new(); + engine.add_filter("lower", str::to_lowercase); + engine.add_filter("reverse", |s: &str| String::from_iter(s.chars().rev())); + engine } #[inline] @@ -256,19 +246,16 @@ impl<'engine> Engine<'engine> for upon::Engine<'engine> { (begin_block, end_block): (&'static str, &'static str), (begin_comment, end_comment): (&'static str, &'static str), ) -> Self { - upon::Engine::with_syntax( + let mut engine = upon::Engine::with_syntax( upon::Syntax::builder() .expr(begin_expr, end_expr) .block(begin_block, end_block) .comment(begin_comment, end_comment) .build(), - ) - } - - #[inline] - fn add_filters(&mut self) { - self.add_filter("lower", str::to_lowercase); - self.add_filter("reverse", |s: &str| String::from_iter(s.chars().rev())); + ); + engine.add_filter("lower", str::to_lowercase); + engine.add_filter("reverse", |s: &str| String::from_iter(s.chars().rev())); + engine } #[inline] diff --git a/benches/src/testdata/filters_handlebars.golden b/benches/src/testdata/filters_handlebars.golden index 1bb9f63..99376d6 100644 --- a/benches/src/testdata/filters_handlebars.golden +++ b/benches/src/testdata/filters_handlebars.golden @@ -1 +1,3 @@ -releehw ycnannotgnirrah evetsevorgrah yllib \ No newline at end of file + releehw ycnan + notgnirrah evets + evorgrah yllib diff --git a/benches/src/testdata/literals_minijinja.golden b/benches/src/testdata/literals_minijinja.golden new file mode 100644 index 0000000..a4a1ac5 --- /dev/null +++ b/benches/src/testdata/literals_minijinja.golden @@ -0,0 +1,200 @@ + + Margaret Brewer + + Cruz McCarty + + Halo Rollins + + Wes Velazquez + + Jaliyah Ford + + Luis Mullen + + Shay Navarro + + Reid Glass + + Clare Collins + + Miles Christensen + + Carmen Solomon + + Musa Steele + + Rylie Dunlap + + Aries Miranda + + Amina Davenport + + Dariel Medrano + + Halle Glenn + + Zaid Hahn + + Fallon Wyatt + + Sam Tanner + + Harmoni McBride + + Denver Campos + + Sutton Choi + + Khari Medina + + Elliana Sweeney + + Nixon Andrews + + Payton Bautista + + Raul Callahan + + Kimber Lyons + + Cyrus Hodge + + Coraline Santos + + Walker Navarro + + Winter Ferguson + + Miguel Garza + + River Hartman + + Baker Aguilar + + Josie Cook + + Ezekiel Sawyer + + Marina Schmidt + + Zayden Russell + + Raelynn Mendez + + Arthur Bates + + Madilyn Medina + + George Rangel + + Gloria Henson + + Bellamy Raymond + + Hadlee Case + + Bentlee Kramer + + Hanna Holland + + Brady Douglas + + Aniyah Duffy + + Kyng Morton + + Mallory Green + + Anthony Chandler + + Viviana Shepard + + Damari McCann + + Joyce George + + Mark Reynolds + + Isabelle Andrews + + Lukas Archer + + Kadence Cardenas + + Johnathan Vazquez + + Journee Cohen + + Killian Orozco + + Renata Vega + + Aidan Phillips + + Naomi Evans + + Elias Spence + + Aislinn Strickland + + Keegan Cline + + Lina Trejo + + Wesson Hale + + Brinley Cabrera + + Cade Ibarra + + Madilynn Nunez + + Caden Sharp + + Camryn Hoffman + + Steven Young + + Zoey Gross + + Quinn Allison + + Chelsea Terrell + + Jaxen Russell + + Raelynn Payne + + Edward Gillespie + + Alianna Bernal + + Eithan Lane + + Amy Turner + + Joshua Hester + + Zendaya Camacho + + Tatum Williamson + + Catherine Kaur + + Augustine Hunt + + Genevieve Villanueva + + Huxley Sweeney + + Yara Barajas + + Brennan Carrillo + + Kaylani Ingram + + Tripp Palmer + + Juniper Schroeder + + Izaiah Schultz diff --git a/benches/src/testdata/literals_upon.golden b/benches/src/testdata/literals_upon.golden new file mode 100644 index 0000000..129f734 --- /dev/null +++ b/benches/src/testdata/literals_upon.golden @@ -0,0 +1,201 @@ + + Margaret Brewer + + Cruz McCarty + + Halo Rollins + + Wes Velazquez + + Jaliyah Ford + + Luis Mullen + + Shay Navarro + + Reid Glass + + Clare Collins + + Miles Christensen + + Carmen Solomon + + Musa Steele + + Rylie Dunlap + + Aries Miranda + + Amina Davenport + + Dariel Medrano + + Halle Glenn + + Zaid Hahn + + Fallon Wyatt + + Sam Tanner + + Harmoni McBride + + Denver Campos + + Sutton Choi + + Khari Medina + + Elliana Sweeney + + Nixon Andrews + + Payton Bautista + + Raul Callahan + + Kimber Lyons + + Cyrus Hodge + + Coraline Santos + + Walker Navarro + + Winter Ferguson + + Miguel Garza + + River Hartman + + Baker Aguilar + + Josie Cook + + Ezekiel Sawyer + + Marina Schmidt + + Zayden Russell + + Raelynn Mendez + + Arthur Bates + + Madilyn Medina + + George Rangel + + Gloria Henson + + Bellamy Raymond + + Hadlee Case + + Bentlee Kramer + + Hanna Holland + + Brady Douglas + + Aniyah Duffy + + Kyng Morton + + Mallory Green + + Anthony Chandler + + Viviana Shepard + + Damari McCann + + Joyce George + + Mark Reynolds + + Isabelle Andrews + + Lukas Archer + + Kadence Cardenas + + Johnathan Vazquez + + Journee Cohen + + Killian Orozco + + Renata Vega + + Aidan Phillips + + Naomi Evans + + Elias Spence + + Aislinn Strickland + + Keegan Cline + + Lina Trejo + + Wesson Hale + + Brinley Cabrera + + Cade Ibarra + + Madilynn Nunez + + Caden Sharp + + Camryn Hoffman + + Steven Young + + Zoey Gross + + Quinn Allison + + Chelsea Terrell + + Jaxen Russell + + Raelynn Payne + + Edward Gillespie + + Alianna Bernal + + Eithan Lane + + Amy Turner + + Joshua Hester + + Zendaya Camacho + + Tatum Williamson + + Catherine Kaur + + Augustine Hunt + + Genevieve Villanueva + + Huxley Sweeney + + Yara Barajas + + Brennan Carrillo + + Kaylani Ingram + + Tripp Palmer + + Juniper Schroeder + + Izaiah Schultz + diff --git a/benches/src/tests.rs b/benches/src/tests.rs index 02eb7d3..c6e49ff 100644 --- a/benches/src/tests.rs +++ b/benches/src/tests.rs @@ -3,21 +3,14 @@ use crate::{Engine, Handlebars, Liquid, Minijinja, Tera, TinyTemplate, Upon}; macro_rules! t { ($E:ty, $source:literal) => {{ - let result = render::<$E>(include_str!($source), false, false); - goldie::assert!(result); - }}; -} - -macro_rules! t_filters { - ($E:ty, $source:literal) => {{ - let result = render::<$E>(include_str!($source), false, true); + let result = render::<$E>(include_str!($source), false); goldie::assert!(result); }}; } macro_rules! t_syntax { ($E:ty, $source:literal) => {{ - let result = render::<$E>(include_str!($source), true, false); + let result = render::<$E>(include_str!($source), true); goldie::assert!(result); }}; } @@ -33,12 +26,12 @@ fn basic_liquid() { #[test] fn basic_minijinja() { - t!(Minijinja, "../benchdata/basic/minijinja.html"); + t!(Minijinja, "../benchdata/basic/jinja.html"); } #[test] fn basic_tera() { - t!(Tera, "../benchdata/basic/tera.html"); + t!(Tera, "../benchdata/basic/jinja.html"); } #[test] @@ -48,40 +41,50 @@ fn basic_tinytemplate() { #[test] fn basic_upon() { - t!(Upon, "../benchdata/basic/upon.html"); + t!(Upon, "../benchdata/basic/jinja.html"); } #[test] fn filters_handlebars() { - t_filters!(Handlebars, "../benchdata/filters/handlebars.html"); + t!(Handlebars, "../benchdata/filters/handlebars.html"); } #[test] fn filters_minijinja() { - t_filters!(Minijinja, "../benchdata/filters/minijinja.html"); + t!(Minijinja, "../benchdata/filters/jinja.html"); } #[test] fn filters_tera() { - t_filters!(Tera, "../benchdata/filters/tera.html"); + t!(Tera, "../benchdata/filters/jinja.html"); } #[test] fn filters_upon() { - t_filters!(Upon, "../benchdata/filters/upon.html"); + t!(Upon, "../benchdata/filters/jinja.html"); +} + +#[test] +fn literals_minijinja() { + t!(Minijinja, "../benchdata/literals/minijinja.html"); +} + +#[test] +fn literals_upon() { + t!(Upon, "../benchdata/literals/upon.html"); } #[test] fn syntax_minijinja() { - t_syntax!(Minijinja, "../benchdata/syntax/minijinja.html"); + t_syntax!(Minijinja, "../benchdata/syntax/jinja.html"); } #[test] fn syntax_upon() { - t_syntax!(Upon, "../benchdata/syntax/upon.html"); + t_syntax!(Upon, "../benchdata/syntax/jinja.html"); } -fn render<'a, E: Engine<'a>>(source: &'a str, syntax: bool, filters: bool) -> String { +fn render<'a, E: Engine<'a>>(source: &'a str, syntax: bool) -> String { let ctx = Context { title: "My awesome webpage!".to_owned(), users: vec![ @@ -108,9 +111,6 @@ fn render<'a, E: Engine<'a>>(source: &'a str, syntax: bool, filters: bool) -> St } else { E::new() }; - if filters { - engine.add_filters(); - } engine.add_template("bench", source); engine.render("bench", &ctx) } diff --git a/clippy.toml b/clippy.toml index 13f202e..64aceb7 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.60" +msrv = "1.66" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index bb2c9d8..ba9ca95 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -8,8 +8,8 @@ publish = false cargo-fuzz = true [dependencies] -arbitrary = { version = "1.3.0", features = ["derive"] } -libfuzzer-sys = "0.4.6" +arbitrary = { version = "1.4.1", features = ["derive"] } +libfuzzer-sys = "0.4.8" serde = { version = "1.0.137", features = ["derive"] } upon = { path = ".." } diff --git a/onedoc.toml b/onedoc.toml index a60b97f..777bf14 100644 --- a/onedoc.toml +++ b/onedoc.toml @@ -14,6 +14,7 @@ template = "docs/SYNTAX_TEMPLATE.md" "Value" = "https://docs.rs/upon/latest/upon/enum.Value.html" # Engine methods +"Engine::with_syntax" = "https://docs.rs/upon/latest/upon/struct.Engine.html#method.with_syntax" "Engine::add_filter" = "https://docs.rs/upon/latest/upon/struct.Engine.html#method.add_filter" "Engine::add_formatter" = "https://docs.rs/upon/latest/upon/struct.Engine.html#method.add_formatter" "add_template(..)" = "https://docs.rs/upon/latest/upon/struct.Engine.html#method.add_template" @@ -36,6 +37,7 @@ template = "docs/SYNTAX_TEMPLATE.md" "std::io::Write" = "https://doc.rust-lang.org/stable/std/io/trait.Write.html" # Crates +"aho-corasick" = "https://crates.io/crates/aho-corasick" "serde" = "https://crates.io/crates/serde" "unicode-ident" = "https://crates.io/crates/unicode-ident" "unicode-width" = "https://crates.io/crates/unicode-width" diff --git a/src/lib.rs b/src/lib.rs index dc5aa5d..c03354d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,9 +48,8 @@ //! //! ## MSRV //! -//! Currently the minimum supported version for `upon` is Rust 1.65. Disabling -//! the **`filters`** feature reduces it to Rust 1.60. The MSRV will only ever -//! be increased in a breaking release. +//! Currently the minimum supported version for `upon` is Rust 1.66. The MSRV +//! will only ever be increased in a breaking release. //! //! # Getting started //! diff --git a/tools/gen-filters/Cargo.toml b/tools/gen-filters/Cargo.toml index 6831156..56868ad 100644 --- a/tools/gen-filters/Cargo.toml +++ b/tools/gen-filters/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" publish = false [dependencies] -either = "1.9.0" -itertools = "0.10.5" +either = "1.13.0" +itertools = "0.14.0"