Skip to content

Instantly share code, notes, and snippets.

@stevencwarren
Created July 17, 2012 15:48
Show Gist options
  • Select an option

  • Save stevencwarren/3130218 to your computer and use it in GitHub Desktop.

Select an option

Save stevencwarren/3130218 to your computer and use it in GitHub Desktop.
def export_to_js(name, value, opts={})
s = <<RUBY
<script type="text/javascript">
DATA['#{name}'] = #{value.to_json(opts).html_safe};
</script>
RUBY
s.html_safe
end
put this in the application helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment