Repository: mitsuhiko/minijinja
Pull request #640 (2024-11-08 13:05:12)

add qsv's use of MiniJinja
Hope it makes the cut! :smile:


Patch:
diff --git a/README.md b/README.md
index 0bd4e7e..2a29de2 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,8 @@ the engine is used so you can see how it's utilized:
 * Data and Processing:
   * **[Cube](https://cube.dev/docs/product/data-modeling/dynamic/jinja)** uses it [for data modelling](https://github.com/cube-js/cube/tree/db11c121c77c663845242366d3d972b9bc30ae54/packages/cubejs-backend-native/src/template/mj_value)
   * **[PRQL](https://prql-lang.org/)** uses it [to handle DBT style pipelines](https://github.com/PRQL/prql/blob/59fb3cc4b9b6c9e195c928b1ba1134e2c5706ea3/prqlc/prqlc/src/cli/jinja.rs#L21)
+  * **[qsv](https://qsv.dathere.com)** uses it [to render templates from CSV files](https://github.com/jqnatividad/qsv/blob/master/src/cmd/template.rs#L2) and to [construct payloads to post to web services](https://github.com/jqnatividad/qsv/blob/master/src/cmd/fetchpost.rs#L3).
+
 
 ## Getting Help
 
diff --git a/UPDATING.md b/UPDATING.md
index 80059de..5011247 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -1,7 +1,7 @@
 # Updating to MiniJinja 2
 
 MiniJinja 2.0 is a major update to MiniJinja that changes a lot of core
-internals and cleans up some APIs.  In particular it resolves somes limitations
+internals and cleans up some APIs.  In particular it resolves some limitations
 in the engine in relation to working with dynamic objects, unlocks potentials
 for future performance improvements and enhancements.  This document helps with
 upgrading to that version.
@@ -93,12 +93,12 @@ In a nutshell:
 
 When working with objects of an unknown type, you can use the new `DynObject`
 struct which is a type erased box over `Arc<Object>`.  `Value::as_object` now
-returns an `Option<&DynObject>` compared to previosly an `Option<&dyn Object>`
+returns an `Option<&DynObject>` compared to previously an `Option<&dyn Object>`
 as an example.  The `DynObject` can be cheaply cloned which bumps the reference
 count.
 
 On the value type, the object related APIs were changed a bit to better
-accomodate for the new trait:
+accommodate for the new trait:
 
 * `Value::as_struct` was removed, use `Value::as_object` instead.
 * `Value::as_seq` was removed, use `Value::as_object` instead.
@@ -313,7 +313,7 @@ impl Object for Markdown {
 
 ## Stack Ref
 
-The old `minijinja-stack-ref` module was removed as it can no longer accomodate the
+The old `minijinja-stack-ref` module was removed as it can no longer accommodate the
 new object model.  However that module largely is no longer useful as the new object
 system is powerful enough to support it _for the most part_.  While it's not possible
 any more to return references to objects on the stack, you can now trivially work with
diff --git a/minijinja-cabi/include/minijinja.h b/minijinja-cabi/include/minijinja.h
index f7f381a..b312912 100644
--- a/minijinja-cabi/include/minijinja.h
+++ b/minijinja-cabi/include/minijinja.h
@@ -288,7 +288,7 @@ MINIJINJA_API struct mj_value mj_value_get_by_index(struct mj_value value, uint6
 MINIJINJA_API struct mj_value mj_value_get_by_str(struct mj_value value, const char *key);
 
 /*
- Looks up an element by a vaue
+ Looks up an element by a value
  */
 MINIJINJA_API struct mj_value mj_value_get_by_value(struct mj_value value, struct mj_value key);
 
diff --git a/minijinja-cabi/src/value.rs b/minijinja-cabi/src/value.rs
index 3738e93..03d2a73 100644
--- a/minijinja-cabi/src/value.rs
+++ b/minijinja-cabi/src/value.rs
@@ -40,7 +40,7 @@ where
 #[repr(C)]
 pub struct mj_value {
     // Motivation on the size here: The size of `Value` is really not
-    // known and since cbindgen has no way to guarnatee us a matching
+    // known and since cbindgen has no way to guarantee us a matching
     // size we have to be creative.  The dominating type size wise is
     // most likely going to be SmallStr which is a u8+[u8; 22] plus the
     // enum discriminant (u8).
@@ -335,7 +335,7 @@ ffi_fn! {
 }
 
 ffi_fn! {
-    /// Looks up an element by a vaue
+    /// Looks up an element by a value
     unsafe fn mj_value_get_by_value(_scope, value: mj_value, key: mj_value) -> mj_value {
         value.get_item(&key as &Value).unwrap_or_default().into()
     }
diff --git a/minijinja-cli/src/command.rs b/minijinja-cli/src/command.rs
index bee8e32..7432230 100644
--- a/minijinja-cli/src/command.rs
+++ b/minijinja-cli/src/command.rs
@@ -279,7 +279,7 @@ pub(super) fn make_command() -> Command {
                 .long_help("\
                     Dump internals of a template to stdout.\n\n\
                     \
-                    This feature is primarily useful to debug what is going on in a MiniJinja tempalte. \
+                    This feature is primarily useful to debug what is going on in a MiniJinja template. \
                     'instructions' will dump out the bytecode that the engine generated, 'ast' dumps out \
                     the AST in a text only format and 'tokens' will print a line per token of the template \
                     after lexing.")
diff --git a/minijinja-cli/src/long_help.txt b/minijinja-cli/src/long_help.txt
index 33d3b21..f221b8a 100644
--- a/minijinja-cli/src/long_help.txt
+++ b/minijinja-cli/src/long_help.txt
@@ -2,7 +2,7 @@ Most of the functionality is handled via options, but there are two positional a
 
 Various file formats are supported for the template context, the exact formats depend on the features enabled at compilation time.
 
-Configuration is loaded from $HOME/minijinja.toml and environment variables, before being overridden by command line options.  The environment variables are documented with the options that they correspond to.  Note that flags (boolen values) are reconfigured with true/false or 1/0 respectively.  For instance --no-include corresponds to MINIJINJA_INCLUDE=false.  Not all options can be configured from environment variables or config options.
+Configuration is loaded from $HOME/minijinja.toml and environment variables, before being overridden by command line options.  The environment variables are documented with the options that they correspond to.  Note that flags (boolean values) are reconfigured with true/false or 1/0 respectively.  For instance --no-include corresponds to MINIJINJA_INCLUDE=false.  Not all options can be configured from environment variables or config options.
 
 Examples:
 
@@ -14,4 +14,4 @@ Examples:
 
     minijinja-cli --template="Hello {{ name }}!" -Dname=World
 
-    minijinja-cli --expr "1 + 1"
\ No newline at end of file
+    minijinja-cli --expr "1 + 1"
diff --git a/minijinja-embed/src/lib.rs b/minijinja-embed/src/lib.rs
index 319edeb..aa719fa 100644
--- a/minijinja-embed/src/lib.rs
+++ b/minijinja-embed/src/lib.rs
@@ -59,8 +59,8 @@ use std::path::Path;
 /// # }
 /// ```
 ///
-/// To embed diffent folders, alternative bundle names can be provided.
-/// Also tempaltes can be filtered down by extension to avoid accidentally
+/// To embed different folders, alternative bundle names can be provided.
+/// Also templates can be filtered down by extension to avoid accidentally
 /// including unexpected templates.
 ///
 /// ```rust
diff --git a/minijinja/src/compiler/codegen.rs b/minijinja/src/compiler/codegen.rs
index f5550d9..007b8e4 100644
--- a/minijinja/src/compiler/codegen.rs
+++ b/minijinja/src/compiler/codegen.rs
@@ -525,7 +525,7 @@ impl<'source> CodeGenerator<'source> {
 
         // filter expressions work like a nested for loop without
         // the special loop variable. in one loop, the condition is checked and
-        // passing items accumlated into a list. in the second, that list is
+        // passing items accumulated into a list. in the second, that list is
         // iterated over normally
         if let Some(ref filter_expr) = for_loop.filter_expr {
             self.add(Instruction::LoadConst(Value::from(0usize)));
diff --git a/minijinja/src/filters.rs b/minijinja/src/filters.rs
index d324c93..535c0f4 100644
--- a/minijinja/src/filters.rs
+++ b/minijinja/src/filters.rs
@@ -1384,7 +1384,7 @@ mod builtins {
     /// The attribute can use dot notation for nested access, like `"address.city"``.
     /// The values are sorted first so only one group is returned for each unique value.
     /// The attribute can be passed as first argument or as keyword argument named
-    /// `atttribute`.
+    /// `attribute`.
     ///
     /// For example, a list of User objects with a city attribute can be
     /// rendered in groups. In this example, grouper refers to the city value of
diff --git a/minijinja/src/lib.rs b/minijinja/src/lib.rs
index 0557aef..775ae39 100644
--- a/minijinja/src/lib.rs
+++ b/minijinja/src/lib.rs
@@ -250,7 +250,7 @@ pub use self::value::Value;
 pub use self::macros::__context;
 pub use self::vm::State;
 
-// fowards compatibility
+// forwards compatibility
 #[cfg(not(feature = "serde"))]
 const _: () = {
     #[deprecated(
diff --git a/minijinja/src/value/mod.rs b/minijinja/src/value/mod.rs
index 1fec131..95e577c 100644
--- a/minijinja/src/value/mod.rs
+++ b/minijinja/src/value/mod.rs
@@ -1315,7 +1315,7 @@ impl Value {
     /// * undefined or none: value returned unchanged.
     /// * string and bytes: returns a reversed version of that value
     /// * iterables: returns a reversed version of the iterable.  If the iterable is not
-    ///   reversable itself, it consumes it and then reverses it.
+    ///   reversible itself, it consumes it and then reverses it.
     pub fn reverse(&self) -> Result<Value, Error> {
         match self.0 {
             ValueRepr::Undefined | ValueRepr::None => Some(self.clone()),
diff --git a/minijinja/src/value/object.rs b/minijinja/src/value/object.rs
index b2fe3b9..a77aa49 100644
--- a/minijinja/src/value/object.rs
+++ b/minijinja/src/value/object.rs
@@ -196,7 +196,7 @@ pub trait Object: fmt::Debug + Send + Sync {
     ///
     /// By default the length is taken by calling [`enumerate`](Self::enumerate) and
     /// inspecting the [`Enumerator`].  This means that in order to determine
-    /// the length, an iteration is started.  If you this is a problem for your
+    /// the length, an iteration is started.  If you think this is a problem for your
     /// uses, you can manually implement this.  This might for instance be
     /// needed if your type can only be iterated over once.
     fn enumerator_len(self: &Arc<Self>) -> Option<usize> {
diff --git a/minijinja/src/value/type_erase.rs b/minijinja/src/value/type_erase.rs
index b966d29..6850f70 100644
--- a/minijinja/src/value/type_erase.rs
+++ b/minijinja/src/value/type_erase.rs
@@ -76,7 +76,7 @@ macro_rules! type_erase {
                     }
                 )*
 
-                /// Returns the type name of the conrete underlying type.
+                /// Returns the type name of the concrete underlying type.
                 $v fn type_name(&self) -> &'static str {
                     (vt(self).__type_name)()
                 }


Test patch:
diff --git a/minijinja-cli/tests/snapshots/test_basic__long_help.snap b/minijinja-cli/tests/snapshots/test_basic__long_help.snap
index 4f6bbca..2c885ed 100644
--- a/minijinja-cli/tests/snapshots/test_basic__long_help.snap
+++ b/minijinja-cli/tests/snapshots/test_basic__long_help.snap
@@ -20,7 +20,7 @@ features enabled at compilation time.
 
 Configuration is loaded from $HOME/minijinja.toml and environment variables, before being overridden
 by command line options.  The environment variables are documented with the options that they
-correspond to.  Note that flags (boolen values) are reconfigured with true/false or 1/0
+correspond to.  Note that flags (boolean values) are reconfigured with true/false or 1/0
 respectively.  For instance --no-include corresponds to MINIJINJA_INCLUDE=false.  Not all options
 can be configured from environment variables or config options.
 
@@ -293,7 +293,7 @@ Advanced:
       --dump <KIND>
           Dump internals of a template to stdout.
           
-          This feature is primarily useful to debug what is going on in a MiniJinja tempalte.
+          This feature is primarily useful to debug what is going on in a MiniJinja template.
           'instructions' will dump out the bytecode that the engine generated, 'ast' dumps out the
           AST in a text only format and 'tokens' will print a line per token of the template after
           lexing.