Ruby to JSON - how to store javascript functions

P

Peter Szinek

[Note: parts of this message were removed to make it a legal post.]

Hey guys,

I am working on a small plug-in which stores settings in a yaml file,
e.g.:

---
:before: var lastsel2;
:params:
:url: http://www.google.com
:datatype: xml
:mtype: GET

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

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

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

:params:
:some_func: ???

so that the Ruby code above spits out this:

some_func: function(id) {
do_some_stuff
do_something_else
}

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?

Cheers,
Peter
___
http://www.rubyrailways.com
http://scrubyt.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,122
Latest member
VinayKumarNevatia_
Top