Skip to content
This repository was archived by the owner on Aug 9, 2026. It is now read-only.
This repository was archived by the owner on Aug 9, 2026. It is now read-only.

Use lambda in a JSON context #23

Description

@tiawl

Hi,

I tried to build this kind of struct to use lambdas with std.json.Value:

const std = @import("std");
const mustache = @import("mustache");

const Native = struct {
    values: std.json.Value,

    pub fn myAwesomeLambda(self: Native, context: mustache.LambdaContext) !void {
        // here I am doing awesome things with Native.values
    }
}

When I give my Native object as data to the renderAllocText function, it fails with this error:

src/rendering/context.zig:86:9: error: Unexpect context_source: json.dynamic.Value of type [json] and context_source == [native]

Which is undeniably correct.

However I am wondering if there are any tips to use lambdas in a JSON context ?
If not, do you plan something like this ?
If not, will you accept a PR implementing this feature ?
If yes, could you give me some tips to make it possible ? Something like how you see the implementation with more or less details. I will be happy to contribute to this awesome project.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions