Forum: Ruby Ruby to JSON - how to store javascript functions

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Peter S. (Guest)
on 2008-12-02 21:43
(Received via mailing list)
Hey guys,

I am working on a small plug-in which stores settings in a yaml file,

:before: var lastsel2;
   :datatype: xml
   :mtype: GET

etc., then later turning them into js with something like

params.each do |key,value|
   emit "#{key}:  #{value.to_json}

so far so good. My question is, what should I put in the place of ???

   :some_func: ???

so that the Ruby code above spits out this:

some_func: function(id) {

I hope it's clear :-) Obviously I'd like to store the function params
and body as well.
Is there a (semi-)standard way of doing this? I thought of
representing the js function with some custom class, storing the param
list and body as strings. Am I completely off?

This topic is locked and can not be replied to.