defmodule LivebookWeb.SessionLive.ExportElixirComponent do use LivebookWeb, :live_component @impl true def update(assigns, socket) do socket = assign(socket, assigns) source = Livebook.Notebook.Export.Elixir.notebook_to_elixir(socket.assigns.notebook) socket = assign(socket, :source, source) {:ok, socket} end @impl true def render(assigns) do ~H"""
Note: the script export is available as a convenience, rather than an exact reproduction of the notebook and in some cases it may not even compile. For example, if you define a macro in one cell and import it in another cell, it works fine in Livebook, because each cell is compiled separately. However, when running the script it gets compiled as a whole and consequently doing so doesn't work. Additionally, branching sections are commented out.