cells-hamlit2 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +8 -0
- data/CHANGES.md +25 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +11 -0
- data/cells-hamlit.gemspec +24 -0
- data/gemfiles/rails_3.2-tilt-1.4.gemfile +15 -0
- data/gemfiles/rails_4.0-tilt-1.4.gemfile +14 -0
- data/gemfiles/rails_4.2-tilt-1.4.gemfile +14 -0
- data/gemfiles/rails_4.2-tilt-2.0.gemfile +15 -0
- data/gemfiles/rails_4.2-tilt-3.0.gemfile +14 -0
- data/lib/cell/hamlit.rb +61 -0
- data/lib/cell/hamlit/version.rb +5 -0
- data/lib/cells-hamlit2.rb +1 -0
- data/test/cell_generator_test.rb +42 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/cells/song/render_in_render.haml +1 -0
- data/test/dummy/app/cells/song/render_in_render_2.haml +1 -0
- data/test/dummy/app/cells/song/render_inside_block.haml +2 -0
- data/test/dummy/app/cells/song/with_capture.haml +11 -0
- data/test/dummy/app/cells/song/with_content_tag.haml +1 -0
- data/test/dummy/app/cells/song/with_content_tag_and_content_tag.haml +4 -0
- data/test/dummy/app/cells/song/with_form_tag_and_content_tag.haml +37 -0
- data/test/dummy/app/cells/song_cell.rb +66 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +35 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +3 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/initializers/cells.rb +0 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/hamlit_test.rb +74 -0
- data/test/test_helper.rb +10 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b36ce2958e1d643066ca1afd006812ca44b07cd5643ac790549f2216e18dd7fe
|
4
|
+
data.tar.gz: 8baeaa3ec13f760c3c3d3b1a1ddd447114f896c6490a7f13dc0c88577bf5ac37
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 050da4421b37a809c9d3f293ed860cd058748a413006b181ac1ddbdf903f51d29654e18c5d37c2b42dcf2de3eeabe7fe81ad808d983743127754715f7ec6a61a
|
7
|
+
data.tar.gz: 3433dd16695d0028a1700b4351bbaadd55797c47457c605ae5c12080f8f60b51a8c8db00a49e41eefd8ee225cadcac2fd1d98c53953a4204f707b82372ce837e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGES.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# 0.1.1
|
2
|
+
|
3
|
+
* Now using `hamlit-block` for capturing.
|
4
|
+
|
5
|
+
# 0.1.0
|
6
|
+
|
7
|
+
Start based on cells-haml
|
8
|
+
|
9
|
+
# 0.0.8
|
10
|
+
|
11
|
+
Require >= haml-4.1.0.beta.1 as haml-rails doesn't know about its 5.0 compatibility, yet. You need to use commit , ref: `7c7c169`.
|
12
|
+
|
13
|
+
# 0.0.7
|
14
|
+
|
15
|
+
Require >= haml-5.0.0.beta2.
|
16
|
+
|
17
|
+
# 0.0.6
|
18
|
+
|
19
|
+
# 0.0.5
|
20
|
+
|
21
|
+
* Remove Haml's buggy `#form_for` version until Haml 4.1 is out, which fixes this by simply not overriding the helper at all. Include `Cell::Haml` after including the form helpers.
|
22
|
+
|
23
|
+
# 0.0.4
|
24
|
+
|
25
|
+
* Added `capture` helper to override Rails escaping.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014-2015 Abdelkader Boudih & Nick Sutterer & Timo Schilling
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# cells-hamlit2
|
2
|
+
|
3
|
+
Temporary workaround version of [cells-hamlit](https://github.com/trailblazer/cells-hamlit) until https://github.com/trailblazer/cells-hamlit/issues/6 is closed.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add these lines to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "cells-hamlit2"
|
12
|
+
gem "hamlit"
|
13
|
+
```
|
14
|
+
|
15
|
+
## HTML Escaping
|
16
|
+
|
17
|
+
Cells doesn't escape except when you tell it to do. However, you may run into problems when using Rails helpers. Internally, those helpers often blindly escape. This is not Cells' fault but a design flaw in Rails.
|
18
|
+
|
19
|
+
As a first step, try this and see if it helps.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
class SongCell < Cell::ViewModel
|
23
|
+
include ActionView::Helpers::FormHelper
|
24
|
+
include Cell::Hamlit # include Haml _after_ AV helpers.
|
25
|
+
|
26
|
+
# ..
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
If that doesn't work, [read the docs](http://trailblazerb.org/gems/cells/cells4.html#html-escaping).
|
31
|
+
|
32
|
+
## Dependencies
|
33
|
+
|
34
|
+
This gem works with Tilt 1.4 and 2.0, and hence allows you to use it from Rails 3.2 upwards.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path("../lib/", __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
3
|
+
|
4
|
+
require "cell/hamlit/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cells-hamlit2"
|
8
|
+
spec.version = Cell::Hamlit::VERSION
|
9
|
+
spec.authors = ["Nick Sutterer", "Timo Schilling"]
|
10
|
+
spec.email = %w(apotonick@gmail.com timo@schilling.io)
|
11
|
+
spec.summary = "Temporary Hamlit integration for Cells"
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/hamlit/cells-hamlit2"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "cells", "~> 4.0"
|
21
|
+
spec.add_dependency "hamlit"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
#gem "cells", :github => "apotonick/cells"
|
6
|
+
# gem "cells", path: "../../cells"
|
7
|
+
gem "railties", "~> 3.2.0"
|
8
|
+
gem "activemodel"
|
9
|
+
gem "minitest", "~> 4.0"
|
10
|
+
gem "tilt", "~> 1.4"
|
11
|
+
gem "tzinfo"
|
12
|
+
|
13
|
+
gemspec :path => "../"
|
14
|
+
|
15
|
+
gem "hamlit"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
#gem "cells", :github => "apotonick/cells"
|
6
|
+
# gem "cells", path: "../../cells"
|
7
|
+
gem "railties", "~> 4.0.0"
|
8
|
+
gem "activemodel"
|
9
|
+
gem "minitest", "~> 4.0"
|
10
|
+
gem "tilt", "~> 1.4"
|
11
|
+
|
12
|
+
gemspec :path => "../"
|
13
|
+
|
14
|
+
gem "hamlit"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# gem "cells", :github => "apotonick/cells"
|
6
|
+
#gem "cells", path: "../../cells"
|
7
|
+
gem "railties", "~> 4.2.0"
|
8
|
+
gem "activemodel"
|
9
|
+
gem "minitest", "~> 5.2"
|
10
|
+
gem "tilt", "~> 1.4"
|
11
|
+
|
12
|
+
gemspec :path => "../"
|
13
|
+
|
14
|
+
gem "hamlit"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# gem "cells", :github => "apotonick/cells"
|
6
|
+
# gem "cells", path: "../../cells"
|
7
|
+
gem "cells", github: "apotonick/cells"
|
8
|
+
gem "railties", "~> 4.2.0"
|
9
|
+
gem "activemodel"
|
10
|
+
gem "minitest", "~> 5.2"
|
11
|
+
gem "tilt", "~> 2.0"
|
12
|
+
|
13
|
+
gemspec :path => "../"
|
14
|
+
|
15
|
+
gem "hamlit"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# gem "cells", :github => "apotonick/cells"
|
6
|
+
#gem "cells", path: "../../cells"
|
7
|
+
gem "railties", "~> 4.2.0"
|
8
|
+
gem "activemodel"
|
9
|
+
gem "minitest", "~> 5.2"
|
10
|
+
gem "tilt", "~> 3.0"
|
11
|
+
|
12
|
+
gemspec :path => "../"
|
13
|
+
|
14
|
+
gem "hamlit"
|
data/lib/cell/hamlit.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "hamlit"
|
2
|
+
|
3
|
+
module Cell
|
4
|
+
module Hamlit
|
5
|
+
def template_options_for(options)
|
6
|
+
{
|
7
|
+
escape_html: false,
|
8
|
+
template_class: ::Hamlit::Template,
|
9
|
+
suffix: "haml",
|
10
|
+
buffer: '@output_buffer',
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# include ActionView::Helpers::FormHelper
|
15
|
+
|
16
|
+
# From FormTagHelper. why do they escape every possible string? why?
|
17
|
+
def form_tag_in_block(html_options, &block)
|
18
|
+
content = capture(&block)
|
19
|
+
form_tag_with_body(html_options, content)
|
20
|
+
end
|
21
|
+
|
22
|
+
def form_tag_with_body(html_options, content)
|
23
|
+
"#{form_tag_html(html_options)}" << content.to_s << "</form>"
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_output_buffer(block_buffer=ViewModel::OutputBuffer.new)
|
27
|
+
@output_buffer, old_buffer = block_buffer, @output_buffer
|
28
|
+
yield
|
29
|
+
block_buffer
|
30
|
+
ensure
|
31
|
+
@output_buffer = old_buffer
|
32
|
+
end
|
33
|
+
|
34
|
+
def capture(*args)
|
35
|
+
value = nil
|
36
|
+
buffer = with_output_buffer { value = yield(*args) }
|
37
|
+
buffer.to_s if buffer.size > 0
|
38
|
+
value
|
39
|
+
end
|
40
|
+
|
41
|
+
def render_template(*)
|
42
|
+
old_output_buffer = @output_buffer
|
43
|
+
super
|
44
|
+
ensure
|
45
|
+
@output_buffer = old_output_buffer
|
46
|
+
end
|
47
|
+
|
48
|
+
# def form_tag_html(html_options)
|
49
|
+
# extra_tags = extra_tags_for_form(html_options)
|
50
|
+
# "#{tag(:form, html_options, true) + extra_tags}"
|
51
|
+
# end
|
52
|
+
|
53
|
+
# def form_for(*args, &block) # TODO: remove this once Haml 4.1 is out. the form_for_with_haml is buggy.
|
54
|
+
# form_for_without_haml(*args, &block)
|
55
|
+
# end
|
56
|
+
|
57
|
+
def content_tag(name, content_or_options_with_block=nil, options=nil, escape=false, &block)
|
58
|
+
super
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cell/hamlit'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators/test_case'
|
3
|
+
require 'rails/generators/cell/cell_generator'
|
4
|
+
|
5
|
+
class CellGeneratorTest < Rails::Generators::TestCase
|
6
|
+
tests Rails::Generators::CellGenerator
|
7
|
+
destination File.expand_path('../../tmp', File.dirname(__FILE__))
|
8
|
+
setup :prepare_destination
|
9
|
+
|
10
|
+
test 'create the standard assets' do
|
11
|
+
skip("need to be implemented")
|
12
|
+
run_generator %w(blog post latest)
|
13
|
+
|
14
|
+
assert_file 'app/cells/blog_cell.rb', /class BlogCell < Cell::ViewModel/
|
15
|
+
assert_file 'app/cells/blog_cell.rb', /def post/
|
16
|
+
assert_file 'app/cells/blog_cell.rb', /def latest/
|
17
|
+
assert_file 'app/cells/blog/post.haml', %r{app/cells/blog/post\.haml}
|
18
|
+
assert_file 'app/cells/blog/post.haml', %r{<p>}
|
19
|
+
assert_file 'app/cells/blog/latest.haml', %r{app/cells/blog/latest\.haml}
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'create cell that inherits from custom cell class if specified' do
|
23
|
+
run_generator %w(Blog --parent=ApplicationCell)
|
24
|
+
assert_file 'app/cells/blog_cell.rb', /class BlogCell < ApplicationCell/
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'work with namespaces' do
|
28
|
+
skip("need to be implemented")
|
29
|
+
run_generator %w(blog/post latest)
|
30
|
+
assert_file 'app/cells/blog/post_cell.rb', /class Blog::PostCell < Cell::ViewModel/
|
31
|
+
assert_file 'app/cells/blog/post_cell.rb', /def show/
|
32
|
+
assert_file 'app/cells/blog/post_cell.rb', /def latest/
|
33
|
+
assert_file 'app/cells/blog/post/latest.haml', %r{app/cells/blog/post/latest\.haml}
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'work with namespaces and haml' do
|
37
|
+
skip("need to be implemented")
|
38
|
+
run_generator %w(blog/post latest)
|
39
|
+
assert_file 'app/cells/blog/post_cell.rb', /class Blog::PostCell < Cell::ViewModel/
|
40
|
+
assert_file 'app/cells/blog/post/latest.haml', %r{app/cells/blog/post/latest\.haml}
|
41
|
+
end
|
42
|
+
end
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1 @@
|
|
1
|
+
%b Questions: #{render :render_in_render_2}
|
@@ -0,0 +1 @@
|
|
1
|
+
Yes!
|
@@ -0,0 +1 @@
|
|
1
|
+
= content_tag(:div) { "Beachparty" }
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Word.
|
2
|
+
|
3
|
+
= form_tag "/erubis/is/horribly/outdated" do
|
4
|
+
= text_field_tag :id
|
5
|
+
= link_to "/rails/sucks" do
|
6
|
+
hallo
|
7
|
+
.row
|
8
|
+
Cool
|
9
|
+
|
10
|
+
|
11
|
+
= content_tag(:ul) do
|
12
|
+
Hallo
|
13
|
+
|
14
|
+
- answer = "<script>oui!</script>"
|
15
|
+
|
16
|
+
-# test content rendering in capture.
|
17
|
+
- content = capture do
|
18
|
+
Bonjour!
|
19
|
+
= link_to "Coffee?", "/coffee"
|
20
|
+
<b>Yes please!</b>
|
21
|
+
= answer
|
22
|
+
|
23
|
+
Weiter!
|
24
|
+
|
25
|
+
= content
|
26
|
+
|
27
|
+
- breadcrumbs = capture do
|
28
|
+
= [link_to("1", "/1"), link_to("2", "/2")].join("+")
|
29
|
+
|
30
|
+
= breadcrumbs
|
31
|
+
|
32
|
+
= current_page
|
33
|
+
= form_tag_with_body( {url: "/rails/escapes/too/much"}, %{<input type="button"/>})
|
34
|
+
|
35
|
+
|
36
|
+
= form_for OpenStruct.new, url: "/", as: "open" do |f|
|
37
|
+
= f.text_field :id
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class SongCell < Cell::ViewModel
|
2
|
+
self.view_paths = ["test/dummy/app/cells"]
|
3
|
+
|
4
|
+
|
5
|
+
include Cell::Hamlit
|
6
|
+
|
7
|
+
def protect_against_forgery?
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
11
|
+
def with_form_tag_and_content_tag
|
12
|
+
render
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_content_tag_and_content_tag
|
16
|
+
render
|
17
|
+
end
|
18
|
+
|
19
|
+
def with_content_tag
|
20
|
+
render
|
21
|
+
end
|
22
|
+
|
23
|
+
def with_block
|
24
|
+
render
|
25
|
+
end
|
26
|
+
|
27
|
+
def with_capture
|
28
|
+
render
|
29
|
+
end
|
30
|
+
|
31
|
+
def with_form_tag
|
32
|
+
form_tag("/songs") + content_tag(:span) + "</form>"
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_link_to
|
36
|
+
render
|
37
|
+
end
|
38
|
+
|
39
|
+
def with_form_for_block
|
40
|
+
render
|
41
|
+
end
|
42
|
+
|
43
|
+
def render_in_render
|
44
|
+
render
|
45
|
+
end
|
46
|
+
|
47
|
+
def render_inside_block
|
48
|
+
render
|
49
|
+
end
|
50
|
+
|
51
|
+
def with_capture
|
52
|
+
render
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
def cap
|
57
|
+
"yay, #{with_output_buffer { yield } }"
|
58
|
+
end
|
59
|
+
|
60
|
+
def current_page
|
61
|
+
capture do # FIXME: this escapes!
|
62
|
+
#[link_to("1", "/1"), link_to("2", "/2")].join("+") # this breaks, too!
|
63
|
+
"<b>No current page!<b>".html_safe
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails'
|
4
|
+
require 'action_controller/railtie'
|
5
|
+
require 'action_view/railtie'
|
6
|
+
require 'cell/railtie'
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
config.i18n.enforce_available_locales = false
|
11
|
+
|
12
|
+
config.cache_store = :memory_store
|
13
|
+
config.secret_token = SecureRandom.uuid
|
14
|
+
config.secret_key_base = SecureRandom.uuid
|
15
|
+
|
16
|
+
# enable asset pipeline as in development.
|
17
|
+
config.assets.enabled = true
|
18
|
+
config.assets.compile = true
|
19
|
+
config.cache_classes = true
|
20
|
+
|
21
|
+
# Show full error reports and disable caching
|
22
|
+
config.consider_all_requests_local = true
|
23
|
+
config.action_controller.perform_caching = false
|
24
|
+
|
25
|
+
# Raise exceptions instead of rendering exception templates
|
26
|
+
config.action_dispatch.show_exceptions = false
|
27
|
+
|
28
|
+
# Disable request forgery protection in test environment
|
29
|
+
config.action_controller.allow_forgery_protection = false
|
30
|
+
config.active_support.deprecation = :stderr
|
31
|
+
|
32
|
+
config.eager_load = false
|
33
|
+
config.active_support.test_order = :random
|
34
|
+
end
|
35
|
+
end
|
File without changes
|
data/test/hamlit_test.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class HamlitTest < MiniTest::Spec
|
4
|
+
let (:controller) { ApplicationController.new.tap { |ctl| ctl.send("request=", ActionDispatch::Request.new({})) } }
|
5
|
+
let (:song_cell) { SongCell.new(nil, controller: controller) }
|
6
|
+
|
7
|
+
# render in render
|
8
|
+
it { song_cell.(:render_in_render).must_equal "<b>Questions: Yes!\n</b>\n" }
|
9
|
+
|
10
|
+
# Original Hamlit's behavior
|
11
|
+
it { song_cell.(:render_inside_block).must_equal "0\n1\n2\n" }
|
12
|
+
|
13
|
+
# URL helpers work in cell instance.
|
14
|
+
it { song_cell.songs_path.must_equal "/songs" }
|
15
|
+
|
16
|
+
# content_tag { }
|
17
|
+
it { song_cell.(:with_content_tag).must_equal "<div>Beachparty</div>\n" }
|
18
|
+
|
19
|
+
# content_tag { content_tag { } }
|
20
|
+
it do song_cell.(:with_content_tag_and_content_tag).must_equal %{<span>Title:
|
21
|
+
<div>Still Knee Deep
|
22
|
+
</div></span>}
|
23
|
+
end
|
24
|
+
|
25
|
+
# form_tag { content_tag { } }
|
26
|
+
it( "xxx") do
|
27
|
+
form_tag = "<form action=\"/erubis/is/horribly/outdated\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" />"
|
28
|
+
form_tag = "<form accept-charset=\"UTF-8\" action=\"/erubis/is/horribly/outdated\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div>" if ActionPack::VERSION::MAJOR == 3
|
29
|
+
|
30
|
+
input_tag = %{<input type="text" name="id" id="id" />}
|
31
|
+
input_tag = "<input id=\"id\" name=\"id\" type=\"text\" />" if ActionPack::VERSION::MAJOR == 3
|
32
|
+
|
33
|
+
form_with_body_tag = "<form url=\"/rails/escapes/too/much\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"button\"/></form>"
|
34
|
+
form_with_body_tag = "<form method=\"post\" url=\"/rails/escapes/too/much\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div><input type=\"button\"/></form>" if ActionPack::VERSION::MAJOR == 3
|
35
|
+
|
36
|
+
form_for_tag = "<form class=\"new_open\" id=\"new_open\" action=\"/\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"text\" name=\"open[id]\" id=\"open_id\" />"
|
37
|
+
form_for_tag = "<form accept-charset=\"UTF-8\" action=\"/\" class=\"new_open\" id=\"new_open\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div><input id=\"open_id\" name=\"open[id]\" size=\"30\" type=\"text\" />" if ActionPack::VERSION::MAJOR == 3
|
38
|
+
|
39
|
+
song_cell.(:with_form_tag_and_content_tag).gsub("\n", "").must_equal %{Word.
|
40
|
+
#{form_tag}
|
41
|
+
#{input_tag}
|
42
|
+
<a href=\"/rails/sucks\">hallo
|
43
|
+
<div class='row'>
|
44
|
+
Cool
|
45
|
+
</div>
|
46
|
+
</a>
|
47
|
+
<ul>Hallo
|
48
|
+
</ul>
|
49
|
+
</form>
|
50
|
+
Weiter!
|
51
|
+
Bonjour!
|
52
|
+
<a href=\"/coffee\">Coffee?</a>
|
53
|
+
<b>Yes please!</b>
|
54
|
+
<script>oui!</script>
|
55
|
+
<a href=\"/1\">1</a>+<a href=\"/2\">2</a>
|
56
|
+
<b>No current page!<b>
|
57
|
+
#{form_with_body_tag}
|
58
|
+
#{form_for_tag}
|
59
|
+
</form>
|
60
|
+
}.gsub("\n", "")
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "block capture" do
|
64
|
+
it do
|
65
|
+
song_cell.(:with_capture).must_equal %{Hallo
|
66
|
+
<p>
|
67
|
+
More
|
68
|
+
</p>
|
69
|
+
Hidden!
|
70
|
+
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cells-hamlit2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Sutterer
|
8
|
+
- Timo Schilling
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cells
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: hamlit
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description: Temporary Hamlit integration for Cells
|
71
|
+
email:
|
72
|
+
- apotonick@gmail.com
|
73
|
+
- timo@schilling.io
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CHANGES.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- cells-hamlit.gemspec
|
86
|
+
- gemfiles/rails_3.2-tilt-1.4.gemfile
|
87
|
+
- gemfiles/rails_4.0-tilt-1.4.gemfile
|
88
|
+
- gemfiles/rails_4.2-tilt-1.4.gemfile
|
89
|
+
- gemfiles/rails_4.2-tilt-2.0.gemfile
|
90
|
+
- gemfiles/rails_4.2-tilt-3.0.gemfile
|
91
|
+
- lib/cell/hamlit.rb
|
92
|
+
- lib/cell/hamlit/version.rb
|
93
|
+
- lib/cells-hamlit2.rb
|
94
|
+
- test/cell_generator_test.rb
|
95
|
+
- test/dummy/Rakefile
|
96
|
+
- test/dummy/app/cells/song/render_in_render.haml
|
97
|
+
- test/dummy/app/cells/song/render_in_render_2.haml
|
98
|
+
- test/dummy/app/cells/song/render_inside_block.haml
|
99
|
+
- test/dummy/app/cells/song/with_capture.haml
|
100
|
+
- test/dummy/app/cells/song/with_content_tag.haml
|
101
|
+
- test/dummy/app/cells/song/with_content_tag_and_content_tag.haml
|
102
|
+
- test/dummy/app/cells/song/with_form_tag_and_content_tag.haml
|
103
|
+
- test/dummy/app/cells/song_cell.rb
|
104
|
+
- test/dummy/app/controllers/application_controller.rb
|
105
|
+
- test/dummy/config.ru
|
106
|
+
- test/dummy/config/application.rb
|
107
|
+
- test/dummy/config/boot.rb
|
108
|
+
- test/dummy/config/database.yml
|
109
|
+
- test/dummy/config/environment.rb
|
110
|
+
- test/dummy/config/initializers/cells.rb
|
111
|
+
- test/dummy/config/locales/en.yml
|
112
|
+
- test/dummy/config/routes.rb
|
113
|
+
- test/hamlit_test.rb
|
114
|
+
- test/test_helper.rb
|
115
|
+
homepage: https://github.com/hamlit/cells-hamlit2
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.7.2
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Temporary Hamlit integration for Cells
|
139
|
+
test_files:
|
140
|
+
- test/cell_generator_test.rb
|
141
|
+
- test/dummy/Rakefile
|
142
|
+
- test/dummy/app/cells/song/render_in_render.haml
|
143
|
+
- test/dummy/app/cells/song/render_in_render_2.haml
|
144
|
+
- test/dummy/app/cells/song/render_inside_block.haml
|
145
|
+
- test/dummy/app/cells/song/with_capture.haml
|
146
|
+
- test/dummy/app/cells/song/with_content_tag.haml
|
147
|
+
- test/dummy/app/cells/song/with_content_tag_and_content_tag.haml
|
148
|
+
- test/dummy/app/cells/song/with_form_tag_and_content_tag.haml
|
149
|
+
- test/dummy/app/cells/song_cell.rb
|
150
|
+
- test/dummy/app/controllers/application_controller.rb
|
151
|
+
- test/dummy/config.ru
|
152
|
+
- test/dummy/config/application.rb
|
153
|
+
- test/dummy/config/boot.rb
|
154
|
+
- test/dummy/config/database.yml
|
155
|
+
- test/dummy/config/environment.rb
|
156
|
+
- test/dummy/config/initializers/cells.rb
|
157
|
+
- test/dummy/config/locales/en.yml
|
158
|
+
- test/dummy/config/routes.rb
|
159
|
+
- test/hamlit_test.rb
|
160
|
+
- test/test_helper.rb
|