Skip to content

kuahyeow/de_rjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use this to de-RJS your application.

Converts your .rjs code into js.erb compliant code

CAVEATS

dom_id_or_string

page[@record], where @record is a ActiveRecord object would translate to $("<%= dom_id(@record)") perfectly fine.

However, if @var computes to a string, such as @var = "fixed_id", then dom_id(@var) will result in an error. Hence for safety, I have decided to transcode page[@var] to :

$("<%= dom_id_or_string(@var) $>")

You can either choose to visually inspet the diff and manuall replace each occurence back to dom_id, or you can define the following method:

def dom_id_or_string(thing)
  case thing
  when String, Symbol, NilClass
    thing
  else
    dom_id(thing)
  end
end

About

Converts your .rjs code into js.erb compliant code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%