-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42d8b70
commit c5c2bd8
Showing
8 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
@__once__ expr | ||
Evaluate `expr` only once per `@render` call. | ||
""" | ||
macro __once__(expr) | ||
key = QuoteNode(Symbol(string(__module__, ':', __source__))) | ||
io = esc(S"io") | ||
return quote | ||
if $(@__MODULE__)._missing_once_key($io, $key) | ||
$(esc(expr)) | ||
$(@__MODULE__)._add_once_key!($io, $key) | ||
end | ||
nothing | ||
end | ||
end | ||
|
||
function _get_once(io::IO) | ||
once_ref = get(io, :__once__, nothing) | ||
isassigned(once_ref) || (once_ref[] = Set{Symbol}()) | ||
once = once_ref[] | ||
return isnothing(once) ? error("missing `once` object.") : once | ||
end | ||
|
||
_missing_once_key(io::IO, key::Symbol) = !(key in _get_once(io)) | ||
_add_once_key!(io::IO, key::Symbol) = push!(_get_once(io), key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script><button>Click Me</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script><button>Click Me</button><button>Click Me</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><html><head><script src="https://code.jquery.com/jquery-3.6.0.min.js"></script></head><body><h1>Hello, World!</h1><button>Click Me</button></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters