diff --git a/CHANGELOG.md b/CHANGELOG.md index dfd422c9..2fbd41a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * [Media Library] Guard against invalid values for `:sort` option in `MediaLibrary.list_assets/2` * [Content] Guard against invalid values for `:sort` option in `Content.list_layouts/2` * [Content] Guard against invalid values for `:sort` option in `Content.list_pages/2` + * [HEEx Decoder] Handle attr values with `nil` values, for example the `defer` in script tags ## 0.1.0-rc.1 (2024-08-27) diff --git a/lib/beacon/template/heex/heex_decoder.ex b/lib/beacon/template/heex/heex_decoder.ex index 14843e6e..82bc864c 100644 --- a/lib/beacon/template/heex/heex_decoder.ex +++ b/lib/beacon/template/heex/heex_decoder.ex @@ -126,6 +126,10 @@ defmodule Beacon.Template.HEEx.HEExDecoder do [name, "=", ?{, content, ?}] end + defp reconstruct_attr({name, _, _}) do + [name] + end + defp decode_eex_block(ast) do %{"type" => "eex_block", "content" => content, "children" => children} = Jason.decode!(ast) diff --git a/test/beacon/template/heex/heex_decoder_test.exs b/test/beacon/template/heex/heex_decoder_test.exs index 73feaad1..060a4590 100644 --- a/test/beacon/template/heex/heex_decoder_test.exs +++ b/test/beacon/template/heex/heex_decoder_test.exs @@ -162,4 +162,11 @@ defmodule Beacon.Template.HEEx.HEExDecoderTest do test "live data assigns" do assert_equal(~S|<%= @name %>|, %{name: "Beacon"}) end + + test "script tag" do + assert_equal(~S""" + + """) + end end