From 3c2726c521bef8f6f5e30b1f12cbc81b2e0a0ba2 Mon Sep 17 00:00:00 2001 From: Miguel Camba Date: Fri, 1 Dec 2023 21:14:30 +0100 Subject: [PATCH] Add method to render --- lib/beacon/content.ex | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/beacon/content.ex b/lib/beacon/content.ex index cc25c100..4608b163 100644 --- a/lib/beacon/content.ex +++ b/lib/beacon/content.ex @@ -492,6 +492,21 @@ defmodule Beacon.Content do end end + @doc """ + Sets the template of a page based the given `ast`. + + ## Example + + iex> set_page_ast(page, ast) + {:ok, %Page{}} + + """ + @doc type: :pages + @spec set_page_ast(Page.t(), map()) :: {:ok, Page.t()} | {:error, Changeset.t()} + def set_page_ast(%Page{} = page, ast) do + Map.put(page, :template, HEExDecoder.decode(ast)) + end + @doc """ Updates a page.