Skip to content

Conversation

@ehutzelman
Copy link
Contributor

For some JS formatter functions, the regex in renderer#substitute_function_object was not parsing correctly when run under Rails and was returning empty function declarations in the rendered output. I worked with AI for longer than I care to admit to try and create a failing test case to match what I was seeing in Rails. The same JSON getting passed to #substitute_function_object was working in the standalone gem test cases, but not when the gem was running within the Rails application. I'm guessing it has something to do with how JSON conversion is patched within Rails and how strings are being escaped.

For example, the following JS formatter function:

    labels: {
      formatter: {
        function:
        {
          args: "val",
          body: "return new Date(val).getUTCFullYear().toString();"
        }
      }
    }

results in the following rendered content before this change:

"labels":{"formatter":function(){}}},

after this change, it renders the expected content:

"labels":{"formatter":function(val){return new Date(val).getUTCFullYear().toString();}}},

For some functions, the regex was not parsing correctly when run
under Rails and was returning empty function declarations.
@styd styd merged commit 272d60f into styd:master Sep 19, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants