Skip to content

Commit

Permalink
Allow module-qualified @cm_component definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed Jan 7, 2025
1 parent 8078f06 commit 793fe20
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [v2.2.1] - 2025-01-07

### Fixed

- Allow `module`-qualified `@cm_component` definitions [#34]

## [v2.2.0] - 2024-12-09

### Added
Expand Down Expand Up @@ -99,6 +105,7 @@ Initial release.
[v2.0.1]: https://github.com/MichaelHatherly/HypertextTemplates.jl/releases/tag/v2.0.1
[v2.1.0]: https://github.com/MichaelHatherly/HypertextTemplates.jl/releases/tag/v2.1.0
[v2.2.0]: https://github.com/MichaelHatherly/HypertextTemplates.jl/releases/tag/v2.2.0
[v2.2.1]: https://github.com/MichaelHatherly/HypertextTemplates.jl/releases/tag/v2.2.1
[#8]: https://github.com/MichaelHatherly/HypertextTemplates.jl/issues/8
[#10]: https://github.com/MichaelHatherly/HypertextTemplates.jl/issues/10
[#11]: https://github.com/MichaelHatherly/HypertextTemplates.jl/issues/11
Expand All @@ -117,3 +124,4 @@ Initial release.
[#28]: https://github.com/MichaelHatherly/HypertextTemplates.jl/issues/28
[#29]: https://github.com/MichaelHatherly/HypertextTemplates.jl/issues/29
[#30]: https://github.com/MichaelHatherly/HypertextTemplates.jl/issues/30
[#34]: https://github.com/MichaelHatherly/HypertextTemplates.jl/issues/34
6 changes: 3 additions & 3 deletions src/cmfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ macro cm_component(expr)
$(CMFile)(
joinpath($(dir), $(esc(path))),
$(__module__),
$(QuoteNode(Symbol(name))),
$(QuoteNode(name)),
$(QuoteNode(parameters)),
),
)
Expand All @@ -50,7 +50,7 @@ macro cm_component(expr)
$(CMFile)(
joinpath($(dir), $(path)),
$(__module__),
$(QuoteNode(Symbol(name))),
$(QuoteNode(name)),
$(QuoteNode(parameters)),
),
)
Expand All @@ -65,7 +65,7 @@ end
struct CMFile
file::String
mod::Module
name::Symbol
name::Union{Expr,Symbol}
parameters::Vector
end

Expand Down
2 changes: 2 additions & 0 deletions test/references/markdown/markdown-ext.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1 id="header"><a href="#header" class="anchor"></a>Header</h1>
<p>Interpolated value: <span class="julia-value">1</span>.</p>
14 changes: 14 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import HypertextTemplates.Elements: @time
using ReferenceTests
using Test

module ExternalDefs

using HypertextTemplates

function markdown_component_ext end
@deftag macro markdown_component_ext end

end

# Turns off source locations in the rendered HTML such that the reference
# testing does not need to account for that variablity.
function render_test(f, file)
Expand Down Expand Up @@ -68,6 +77,8 @@ end
@cm_component markdown_component(; x) = joinpath(@__DIR__, "markdown.md")
@deftag macro markdown_component end

@cm_component ExternalDefs.markdown_component_ext(; x) = joinpath(@__DIR__, "markdown.md")

@component function streaming(; n::Integer)
@div {class = "streamed"} begin
@ul begin
Expand Down Expand Up @@ -209,6 +220,9 @@ end
render_test("references/markdown/markdown.txt") do io
@render io @markdown_component {x = 1}
end
render_test("references/markdown/markdown-ext.txt") do io
@render io ExternalDefs.@markdown_component_ext {x = 1}
end
end
@testset "Render Root" begin
function render_function()
Expand Down

0 comments on commit 793fe20

Please sign in to comment.