ScalaFiddle comes to Medium
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.
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/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.
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.