Skip to content

Commit

Permalink
fix: meta["partial-data"] might be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Jul 25, 2024
1 parent 975f20a commit da14cc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ partial-data:
> Or used inline: To you I say "{{< partial _hello.md >}}"
> ```
>
> Hello, friend!
> Hello, !
>
> Or used inline: To you I say “Hello, friend!”
> Or used inline: To you I say “Hello, !”
Alternatively, the second argument of the shortcode can point to a
custom key in your YAML frontmatter, e.g.
Expand All @@ -74,7 +74,7 @@ my-data:
> {{< partial _hello.md my-data.friends >}}
> ```
>
> Hello, amigo!
> Hello, !
Another, possibly less convenient, option is to provide JSON in the
shortcode data. Any key-value pair that starts with `{` or `[` will be
Expand Down
16 changes: 9 additions & 7 deletions _extensions/partials/quarto-partials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,20 @@ local function quarto_partial(args, kwargs, meta, raw_args, context)
assert(false, msg)
end
end
else
elseif meta[partial_key] then
partial_data = copy(meta[partial_key])
end

local data_str = pandoc_stringify(partial_data)
if #partial_data > 0 then
local data_str = pandoc_stringify(partial_data)

if type(data_str) == "string" then
quarto.log.error("Please choose a metadata key from your YAML frontmatter that contains a table of partial data.")
assert(false, "Expected a table of partial data in YAML frontmatter key " .. partial_key)
end
if type(data_str) == "string" then
quarto.log.error("Please choose a metadata key from your YAML frontmatter that contains a table of partial data.")
assert(false, "Expected a table of partial data in YAML frontmatter key " .. partial_key)
end

data = data_str
data = data_str
end

for k, v in pairs(kwargs) do
local v_is_json_string = false
Expand Down

0 comments on commit da14cc0

Please sign in to comment.