ScalaFiddle comes to Medium

Otto Chrons
Jun 13, 2017 · 2 min read

One of the main design goals for ScalaFiddle is to make embedding your fiddles easy. Embedding has always been possible through the use of iframes from the very beginning, but today ScalaFiddle introduces support for directly embedding fiddles via embed.ly

To embed a fiddle on platforms using Embedly (like Medium), simply add a link to your fiddle and the service will take care of the rest. Click Run to see what the fiddle code below does!

By default the embedded fiddle will provide interactivity, allowing the reader to run and modify the code. If you just want to provide a static version of the fiddle, with links back to ScalaFiddle, add ?static=true to the URL.

This is https://scalafiddle.io/sf/UbLKYAK/2?static=true

Use these new embedding features to share interactive code snippets in your blog posts or documentation, to make them more interesting to the readers.

Under the hood

ScalaFiddle exposes these embedding features through two oembed endpoints at https://scalafiddle.io/oembed.json and https://scalafiddle.io/oembedstatic.json. As the name implies the latter endpoint always provides the static view and the former an interactive one (which you can override with the static=true parameter). If you have a publishing platform with oembed support, you can use these endpoints to provide automatic embedding of fiddles. ScalaFiddle also exposes the static endpoint as a meta tag in the header of every fiddle page, which may enable even more automatic embedding.

Next steps

In addition to Embedly, ScalaFiddle will soon also support Iframely, another embed provider. Through Iframely we can reach even more platforms, including chat services like Gitter.

ScalaFiddle is Open Source Software and its source code can be found in Github.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade