Code Samples

Inspiration for ways you might want to use Ruby2JS:

  • Stimulus Controller for Shoelace Forms & Turbo – a controller for submitting Shoelace UI forms via Turbo. In the example provided, both the Ruby2JS source and the JavaScript output are shown (which is helpful for seeing just how human-readable the JS code generated by Ruby2JS is). This could be simplifed even further with the help of the new brand-new Stimulus filter.
  • Simple functions for a static Bridgetown site – just an example of how you could write simple “functions” using Ruby2JS and lambdas instead. Also see how Bridgetown is using @ruby2js/webpack-loader within the Webpack config.

Next: Projects