-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove MarkupTemplate specialization.
- Loading branch information
Showing
12 changed files
with
96 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,7 +179,6 @@ def <<(content) | |
end | ||
else | ||
Markup.append(@output, content) | ||
# @output << content | ||
end | ||
end | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
"TEST TEST TEST\n" | ||
<div><p>Hello <World></p> | ||
</div> |
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,4 +1,14 @@ | ||
<?r result = XRB::Template.capture do ?> | ||
test test test | ||
<?r end ?> | ||
#{result.upcase.inspect} | ||
<?r | ||
def my_capture(value = nil, &block) | ||
XRB::Builder.fragment do |builder| | ||
if block_given? | ||
builder.inline(:div) { builder.capture(self, &block) } | ||
else | ||
builder.inline(:div) { builder.text value } | ||
end | ||
end >> block | ||
end | ||
|
||
my_capture do ?> | ||
<p>Hello #{"<World>"}</p> | ||
<?r 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<escaped> |
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 @@ | ||
#{"<escaped>"} |
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,2 @@ | ||
<div><p>Hello <World></p> | ||
</div> |
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,14 @@ | ||
<?r | ||
def my_capture(value = nil, &block) | ||
XRB::Builder.fragment do |builder| | ||
if block_given? | ||
builder.inline(:div) { builder.capture(self, &block) } | ||
else | ||
builder.inline(:div) { builder.text value } | ||
end | ||
end >> block | ||
end | ||
|
||
my_capture do ?> | ||
<p>Hello #{"<World>"}</p> | ||
<?r 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
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,39 +1,39 @@ | ||
#!/usr/bin/env rspec | ||
# frozen_string_literal: true | ||
# #!/usr/bin/env rspec | ||
# # frozen_string_literal: true | ||
|
||
# Released under the MIT License. | ||
# Copyright, 2016-2024, by Samuel Williams. | ||
# # Released under the MIT License. | ||
# # Copyright, 2016-2024, by Samuel Williams. | ||
|
||
require 'xrb' | ||
require 'xrb/markup' | ||
# require 'xrb' | ||
# require 'xrb/markup' | ||
|
||
Model = Struct.new(:text) | ||
# Model = Struct.new(:text) | ||
|
||
describe XRB::MarkupString do | ||
with 'basic template' do | ||
let(:template) {XRB::MarkupTemplate.load_file File.expand_path('.corpus/basic.xrb', __dir__)} | ||
let(:html_text) {"<h1>Hello World</h1>"} | ||
# describe XRB::MarkupString do | ||
# with 'basic template' do | ||
# let(:template) {XRB::MarkupTemplate.load_file File.expand_path('.corpus/basic.xrb', __dir__)} | ||
# let(:html_text) {"<h1>Hello World</h1>"} | ||
|
||
it "should escape unsafe text" do | ||
model = Model.new(html_text) | ||
# it "should escape unsafe text" do | ||
# model = Model.new(html_text) | ||
|
||
expect(template.to_string(model)).to be == "<h1>Hello World</h1>" | ||
end | ||
# expect(template.to_string(model)).to be == "<h1>Hello World</h1>" | ||
# end | ||
|
||
let(:safe_html_text) {XRB::Builder.tag('h1', 'Hello World')} | ||
# let(:safe_html_text) {XRB::Builder.tag('h1', 'Hello World')} | ||
|
||
it "should not escape safe text" do | ||
model = Model.new(safe_html_text) | ||
# it "should not escape safe text" do | ||
# model = Model.new(safe_html_text) | ||
|
||
expect(template.to_string(model)).to be == html_text | ||
end | ||
end | ||
# expect(template.to_string(model)).to be == html_text | ||
# end | ||
# end | ||
|
||
it "should convert nil to empty string" do | ||
markup_string = XRB::MarkupString.new | ||
# it "should convert nil to empty string" do | ||
# markup_string = XRB::MarkupString.new | ||
|
||
XRB::Markup.append(markup_string, nil) | ||
# XRB::Markup.append(markup_string, nil) | ||
|
||
expect(markup_string).to be(:empty?) | ||
end | ||
end | ||
# expect(markup_string).to be(:empty?) | ||
# end | ||
# end |