{ :action => :add_to_cart, :id => $_ } do
%= submit_tag "Add to Cart"
% end
END
<% form_remote_tag :url => { :action => :add_to_cart, :id => $_ } do
_erbout.concat(eval(%{ submit_tag "Add to Cart"}).to_s)
end %>
END
end
end
context "cell processor" do
include Amrita2
specify "not cell" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("||aaa").should == false
l.cells.size.should == 0
end
specify "1 cell" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("|||aaa|")
l.cells.size.should == 1
c = l.cells.first
c[:text].should == "aaa"
c[:tag].should == :td
l.get_result_xml.should == "
aaa | "
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("|||aaa") # omit the last |
l.cells.size.should == 1
c = l.cells.first
c[:text].should == "aaa"
c[:tag].should == :td
l.get_result_xml.should == "
aaa | "
end
specify "1 cell with spaces" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("| ||aaa|").should == true
l.cells.size.should == 1
c = l.cells.first
c[:text].should == "aaa"
c[:tag].should == :td
l.get_result_xml.should == "
aaa | "
end
specify "2cell" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("|||aaa|bbb")
l.cells.size.should == 2
c = l.cells.first
c[:text].should == "aaa"
c[:tag].should == :td
c = l.cells[1]
c[:text].should == "bbb"
c[:tag].should == :td
l.get_result_xml.should == "
aaa | bbb | "
end
specify "th and 2cell" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("|||aaa||bbb|ccc|")
l.cells.size.should == 3
c = l.cells.first
c[:text].should == "aaa"
c[:tag].should == :th
c = l.cells[1]
c[:text].should == "bbb"
c[:tag].should == :td
l.get_result_xml.should == "
aaa | bbb | ccc | "
end
specify "1cell and id" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("|||aaa|")
l.parse_line("|id||xxx|")
l.cells.size.should == 1
c = l.cells.first
c[:text].should == "aaa"
c[:tag].should == :td
c["id"].should == "xxx"
l.get_result_xml.should == "
aaa | "
end
specify "1 cell 2 lines" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line("|||aaa|")
l.parse_line("|||bbb|")
l.cells.size.should == 1
c = l.cells.first
c[:text].should == "aaa\nbbb"
c[:tag].should == :td
l.get_result_xml.should == "
aaa\nbbb | "
end
specify "proc" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
"(#{s})"
end
l.parse_line("|||aaa|")
l.cells.size.should == 1
c = l.cells.first
c[:text].should == "aaa"
c[:tag].should == :td
l.get_result_xml.should == "
(aaa) | "
end
specify "real td cells" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line(%[ |||$1, $2|
$3|])
l.cells.size.should == 2
c = l.cells.first
c[:text].should == "$1, $2"
c[:tag].should == :td
l.get_result_xml.should == "
$1, $2 | $3 | "
end
specify "filter in cell" do
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
s
end
l.parse_line(%q[ |||<
:url]>>|])
l.cells.size.should == 1
c = l.cells.first
c[:text].should == "<:url]>>"
c[:tag].should == :td
l.get_result_xml.should == "<:url]>> | "
end
end
context "cell line" do
specify "1 cell" do
p = Amrita2::Core::PreProcessor.new
ret = p.process("|||aaa|")
ret.should == "
aaa | "
end
specify "table" do
p = Amrita2::Core::PreProcessor.new
ret = p.process <<-END
<
$3|
END
ret.should_be_samexml_as <<-END
END
end
specify "table with class" do
p = Amrita2::Core::PreProcessor.new
ret = p.process <<-END
<$3|
END
ret.should_be_samexml_as <<-END
END
end
specify "table with tr line" do
p = Amrita2::Core::PreProcessor.new
ret = p.process <<-END
<$3|
END
ret.should_be_samexml_as <<-END
END
end
end