Tags: fallenwood/minijinja-csharp
Tags
Refine interface of Render (#8) This pull request refactors the `Render` method of the `Template` class in `minijinja/Environment.cs` to provide more type-safe and flexible overloads for rendering templates with different types of context objects. It replaces the previous single method that accepted a generic `object?` with overloads for `IDictionary<string, Value>`, `IDictionary<string, object?>`, and `ITemplateSerializable`. This change simplifies usage and improves clarity in both the implementation and the tests. All test cases are updated to use the new overload for rendering templates without context. ### Template rendering API refactor * Refactored the `Template.Render` method to provide overloads for `IDictionary<string, Value>`, `IDictionary<string, object?>`, and `ITemplateSerializable`, replacing the previous single method that accepted a generic `object?` and a helper for context conversion. This improves type safety and clarity for users. [[1]](diffhunk://#diff-62578f15123609361799a7fdf8794305d7cd2dcc0c6fa6a58f48cba2ee826c74L226-R233) [[2]](diffhunk://#diff-62578f15123609361799a7fdf8794305d7cd2dcc0c6fa6a58f48cba2ee826c74L242-R272) ### Test updates * Updated all test cases to use the new `Render()` overload when no context is provided, replacing calls to `Render(null)` for clarity and consistency with the new API. [[1]](diffhunk://#diff-b43ac3def2a4928a8f7d70c75cfe155f69b96a23cc610be91a97a2ad5b4c332aL22-R22) [[2]](diffhunk://#diff-39a48c80da7b6c6e39ec12b6de59bde07e59f5f907a4b3c95fd8950693a05a46L14-R14) [[3]](diffhunk://#diff-5cc2eb18c6fb914fa9a0d7e762c1949d13ee7e86df662397d57ddad455cff6eaL21-R21) [[4]](diffhunk://#diff-f82b1ed2ade657593112b4d6edaf28850d3dba98f4e3d400cae9957a2c49728dL14-R14) [[5]](diffhunk://#diff-a00604ca27b6fa6a3fb9179bc9b714c829adef720b82bb4d63cc3e7f3ab3b1a6L28-R28) [[6]](diffhunk://#diff-a00604ca27b6fa6a3fb9179bc9b714c829adef720b82bb4d63cc3e7f3ab3b1a6L41-R41) [[7]](diffhunk://#diff-64820f3aeb8c9abc06cd610d86900894f8f1ffd4e8fe77bb37fcb51fe381d04cL15-R15) [[8]](diffhunk://#diff-64820f3aeb8c9abc06cd610d86900894f8f1ffd4e8fe77bb37fcb51fe381d04cL29-R29) [[9]](diffhunk://#diff-64820f3aeb8c9abc06cd610d86900894f8f1ffd4e8fe77bb37fcb51fe381d04cL43-R43) [[10]](diffhunk://#diff-8287624583a23219acfbba987b166a9763c6260d30b077e7ff6b9a34020ce0e0L18-R18) [[11]](diffhunk://#diff-d3a5f60abd6666d04843903d5369c7cb9c34e7b8a6a4d37e3dfaba0e8b93d1ffL20-R20) [[12]](diffhunk://#diff-31308eabd88c489048e906852bd543ad44cf62db4739757dd44bb1d8e2696536L14-R14) [[13]](diffhunk://#diff-31308eabd88c489048e906852bd543ad44cf62db4739757dd44bb1d8e2696536L27-R27) [[14]](diffhunk://#diff-5a5228bdf4ee39a586b60f17e19983130a46620ccaaf2a35d36b14fc618a2705L14-R14) [[15]](diffhunk://#diff-c83f7d42ae21e605add77c1f210b0886c6b70b8c0c4989e95083c2e67ad12d9bL17-R17) [[16]](diffhunk://#diff-9dab7643a9429afefcd128b981e92a053d45658de140af5d78db4c4cf6996162L14-R14) [[17]](diffhunk://#diff-5b6aaecaabc2551d605de810fad956a37f332ece595b409d95fdd876be257035L18-R18) [[18]](diffhunk://#diff-008e503cc3a7f7a1f8981bbc5b6163f997b2b4a54042f2e9bb1c090ab05e97fcL14-R14) [[19]](diffhunk://#diff-055c0fed109a44115182763ee17462ed152522f56d51d6da4d3c061cf64aa8fbL15-R15) [[20]](diffhunk://#diff-055c0fed109a44115182763ee17462ed152522f56d51d6da4d3c061cf64aa8fbL29-R29) [[21]](diffhunk://#diff-055c0fed109a44115182763ee17462ed152522f56d51d6da4d3c061cf64aa8fbL44-R44) [[22]](diffhunk://#diff-0eca07137313879c61321ccec31bda6465d533f473d21de3d83cca4be3846c42L44-R44) [[23]](diffhunk://#diff-975915555c7d2145deef69245d32b75d9a87c6f06749cc656e54b72336e22f3aL14-R14) ### Minor code cleanup * Added a missing `using System;` directive at the top of `minijinja/Environment.cs` for completeness.