-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
SGML#fragment
for marking selective rendering blocks (#842)
- [x] Implement `SGML#fragment` method - [x] Support fragments inside of a cached block
- Loading branch information
Showing
13 changed files
with
397 additions
and
41 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
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
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
test "using a component without a source location" do | ||
refute_raises do | ||
# Intentionally not passing a source location here. | ||
eval <<~RUBY | ||
class Example < Phlex::HTML | ||
def view_template | ||
end | ||
end | ||
RUBY | ||
end | ||
end |
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 |
---|---|---|
@@ -1,13 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
test "using a component without a source location" do | ||
refute_raises do | ||
# Intentionally not passing a source location here. | ||
eval <<~RUBY | ||
class Example < Phlex::HTML | ||
def view_template | ||
end | ||
end | ||
RUBY | ||
CacheStore = Phlex::FIFOCacheStore.new | ||
|
||
class CacheTest < Phlex::HTML | ||
def cache_store = CacheStore | ||
|
||
def initialize(execution_watcher) | ||
@execution_watcher = execution_watcher | ||
end | ||
|
||
def view_template | ||
cache do | ||
@execution_watcher.call | ||
"OK" | ||
end | ||
end | ||
end | ||
|
||
test "caching a block only executes once" do | ||
run_count = 0 | ||
monitor = -> { run_count += 1 } | ||
CacheTest.new(monitor).call | ||
assert_equal run_count, 1 | ||
CacheTest.new(monitor).call | ||
assert_equal run_count, 1 | ||
end |
Oops, something went wrong.