cells-hamlit 0.1.0
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 +21 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -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 +40 -0
- data/lib/cell/hamlit/version.rb +5 -0
- data/lib/cells-hamlit.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/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 +58 -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/dummy/log/test.log +96 -0
- data/test/hamlit_test.rb +62 -0
- data/test/test_helper.rb +10 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1bad7fda55152c7469773eb40abfccedc6fe390f
|
4
|
+
data.tar.gz: 0312993ff12918aa59175a42e743be2aad170b0b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5fe604051170e9a8c3d260cc5ffdf49e7af46faf1065ebed146615586858cc7b063fae9c8983b89578bb34508b784ae45d9207347283dc4789a85d68009b8ad0
|
7
|
+
data.tar.gz: 3b51386a039c184a06a93beaa1b7ca770852ed593d05a8d961e325eb5a6c988c1d1139419e04d26366708840c2252dfc6f244d3d6dd72d369ab13631398dbdd2
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGES.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# 0.1.0
|
2
|
+
|
3
|
+
Start based on cells-haml
|
4
|
+
|
5
|
+
# 0.0.8
|
6
|
+
|
7
|
+
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`.
|
8
|
+
|
9
|
+
# 0.0.7
|
10
|
+
|
11
|
+
Require >= haml-5.0.0.beta2.
|
12
|
+
|
13
|
+
# 0.0.6
|
14
|
+
|
15
|
+
# 0.0.5
|
16
|
+
|
17
|
+
* 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.
|
18
|
+
|
19
|
+
# 0.0.4
|
20
|
+
|
21
|
+
* Added `capture` helper to override Rails escaping.
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in cells-haml.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'cells', path: "../cells"#github: 'apotonick/cells'
|
7
|
+
gem 'railties'
|
8
|
+
gem 'actionpack'
|
9
|
+
gem 'actionview'
|
10
|
+
gem "haml", github:"haml/haml" #"4.1.0.beta1" #github: "haml/haml" # we need 4.1.
|
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,37 @@
|
|
1
|
+
# Cells::Hamlit
|
2
|
+
|
3
|
+
Hamlit support for Cells. [Hamlit](https://github.com/k0kubun/hamlit) is a faster implementation of Haml.
|
4
|
+
|
5
|
+
## Beta
|
6
|
+
|
7
|
+
This gem is not safe for work at the moment!
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "cells-hamlit"
|
15
|
+
gem "hamlit"
|
16
|
+
```
|
17
|
+
|
18
|
+
## HTML Escaping
|
19
|
+
|
20
|
+
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.
|
21
|
+
|
22
|
+
As a first step, try this and see if it helps.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
class SongCell < Cell::ViewModel
|
26
|
+
include ActionView::Helpers::FormHelper
|
27
|
+
include Cell::Hamlit # include Haml _after_ AV helpers.
|
28
|
+
|
29
|
+
# ..
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
If that doesn't work, [read the docs](http://trailblazerb.org/gems/cells/cells4.html#html-escaping).
|
34
|
+
|
35
|
+
## Dependencies
|
36
|
+
|
37
|
+
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-hamlit'
|
8
|
+
spec.version = Cell::Hamlit::VERSION
|
9
|
+
spec.authors = ['Abdelkader Boudih', 'Nick Sutterer', 'Timo Schilling']
|
10
|
+
spec.email = %w(terminale@gmail.com apotonick@gmail.com timo@schilling.io)
|
11
|
+
spec.summary = 'Hamlit integration for Cells'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/trailblazer/cells-hamlit'
|
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.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,40 @@
|
|
1
|
+
require 'hamlit'
|
2
|
+
|
3
|
+
module Cell
|
4
|
+
module Hamlit
|
5
|
+
def template_options_for(options)
|
6
|
+
{
|
7
|
+
template_class: ::Hamlit::Template,
|
8
|
+
escape_html: false,
|
9
|
+
suffix: "haml"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_writer :output_buffer
|
14
|
+
|
15
|
+
include ActionView::Helpers::FormHelper
|
16
|
+
|
17
|
+
# From FormTagHelper. why do they escape every possible string? why?
|
18
|
+
def form_tag_in_block(html_options, &block)
|
19
|
+
content = capture(&block)
|
20
|
+
form_tag_with_body(html_options, content)
|
21
|
+
end
|
22
|
+
|
23
|
+
def form_tag_with_body(html_options, content)
|
24
|
+
"#{form_tag_html(html_options)}" << content.to_s << "</form>"
|
25
|
+
end
|
26
|
+
|
27
|
+
# def form_tag_html(html_options)
|
28
|
+
# extra_tags = extra_tags_for_form(html_options)
|
29
|
+
# "#{tag(:form, html_options, true) + extra_tags}"
|
30
|
+
# end
|
31
|
+
|
32
|
+
# def form_for(*args, &block) # TODO: remove this once Haml 4.1 is out. the form_for_with_haml is buggy.
|
33
|
+
# form_for_without_haml(*args, &block)
|
34
|
+
# end
|
35
|
+
|
36
|
+
# def content_tag(name, content_or_options_with_block=nil, options=nil, escape=false, &block)
|
37
|
+
# super
|
38
|
+
# end
|
39
|
+
end
|
40
|
+
end
|
data/lib/cells-hamlit.rb
ADDED
@@ -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,58 @@
|
|
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
|
+
private
|
48
|
+
def cap
|
49
|
+
"yay, #{with_output_buffer { yield } }"
|
50
|
+
end
|
51
|
+
|
52
|
+
def current_page
|
53
|
+
capture do # FIXME: this escapes!
|
54
|
+
#[link_to("1", "/1"), link_to("2", "/2")].join("+") # this breaks, too!
|
55
|
+
"<b>No current page!<b>".html_safe
|
56
|
+
end
|
57
|
+
end
|
58
|
+
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
|
@@ -0,0 +1,96 @@
|
|
1
|
+
-------------------------------------------------------------------------------------
|
2
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
3
|
+
-------------------------------------------------------------------------------------
|
4
|
+
-----------------------------------------------------
|
5
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
6
|
+
-----------------------------------------------------
|
7
|
+
--------------------------------------------
|
8
|
+
CellGeneratorTest: test_work_with_namespaces
|
9
|
+
--------------------------------------------
|
10
|
+
--------------------------------------------------
|
11
|
+
CellGeneratorTest: test_create_the_standard_assets
|
12
|
+
--------------------------------------------------
|
13
|
+
--------------------------------------------
|
14
|
+
CellGeneratorTest: test_work_with_namespaces
|
15
|
+
--------------------------------------------
|
16
|
+
--------------------------------------------------
|
17
|
+
CellGeneratorTest: test_create_the_standard_assets
|
18
|
+
--------------------------------------------------
|
19
|
+
-------------------------------------------------------------------------------------
|
20
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
21
|
+
-------------------------------------------------------------------------------------
|
22
|
+
-----------------------------------------------------
|
23
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
24
|
+
-----------------------------------------------------
|
25
|
+
-------------------------------------------------------------------------------------
|
26
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
27
|
+
-------------------------------------------------------------------------------------
|
28
|
+
--------------------------------------------
|
29
|
+
CellGeneratorTest: test_work_with_namespaces
|
30
|
+
--------------------------------------------
|
31
|
+
--------------------------------------------------
|
32
|
+
CellGeneratorTest: test_create_the_standard_assets
|
33
|
+
--------------------------------------------------
|
34
|
+
-----------------------------------------------------
|
35
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
36
|
+
-----------------------------------------------------
|
37
|
+
--------------------------------------------
|
38
|
+
CellGeneratorTest: test_work_with_namespaces
|
39
|
+
--------------------------------------------
|
40
|
+
--------------------------------------------------
|
41
|
+
CellGeneratorTest: test_create_the_standard_assets
|
42
|
+
--------------------------------------------------
|
43
|
+
-----------------------------------------------------
|
44
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
45
|
+
-----------------------------------------------------
|
46
|
+
-------------------------------------------------------------------------------------
|
47
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
48
|
+
-------------------------------------------------------------------------------------
|
49
|
+
-----------------------------------------------------
|
50
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
51
|
+
-----------------------------------------------------
|
52
|
+
--------------------------------------------------
|
53
|
+
CellGeneratorTest: test_create_the_standard_assets
|
54
|
+
--------------------------------------------------
|
55
|
+
--------------------------------------------
|
56
|
+
CellGeneratorTest: test_work_with_namespaces
|
57
|
+
--------------------------------------------
|
58
|
+
-------------------------------------------------------------------------------------
|
59
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
60
|
+
-------------------------------------------------------------------------------------
|
61
|
+
-------------------------------------------------------------------------------------
|
62
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
63
|
+
-------------------------------------------------------------------------------------
|
64
|
+
--------------------------------------------------
|
65
|
+
CellGeneratorTest: test_create_the_standard_assets
|
66
|
+
--------------------------------------------------
|
67
|
+
--------------------------------------------
|
68
|
+
CellGeneratorTest: test_work_with_namespaces
|
69
|
+
--------------------------------------------
|
70
|
+
-----------------------------------------------------
|
71
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
72
|
+
-----------------------------------------------------
|
73
|
+
-------------------------------------------------------------------------------------
|
74
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
75
|
+
-------------------------------------------------------------------------------------
|
76
|
+
--------------------------------------------
|
77
|
+
CellGeneratorTest: test_work_with_namespaces
|
78
|
+
--------------------------------------------
|
79
|
+
--------------------------------------------------
|
80
|
+
CellGeneratorTest: test_create_the_standard_assets
|
81
|
+
--------------------------------------------------
|
82
|
+
-----------------------------------------------------
|
83
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
84
|
+
-----------------------------------------------------
|
85
|
+
--------------------------------------------------
|
86
|
+
CellGeneratorTest: test_create_the_standard_assets
|
87
|
+
--------------------------------------------------
|
88
|
+
--------------------------------------------
|
89
|
+
CellGeneratorTest: test_work_with_namespaces
|
90
|
+
--------------------------------------------
|
91
|
+
-------------------------------------------------------------------------------------
|
92
|
+
CellGeneratorTest: test_create_cell_that_inherits_from_custom_cell_class_if_specified
|
93
|
+
-------------------------------------------------------------------------------------
|
94
|
+
-----------------------------------------------------
|
95
|
+
CellGeneratorTest: test_work_with_namespaces_and_haml
|
96
|
+
-----------------------------------------------------
|
data/test/hamlit_test.rb
ADDED
@@ -0,0 +1,62 @@
|
|
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
|
+
# URL helpers work in cell instance.
|
11
|
+
it { song_cell.songs_path.must_equal "/songs" }
|
12
|
+
|
13
|
+
# content_tag { }
|
14
|
+
it { song_cell.(:with_content_tag).must_equal "<div>Beachparty</div>\n" }
|
15
|
+
|
16
|
+
# content_tag { content_tag { } }
|
17
|
+
it do song_cell.(:with_content_tag_and_content_tag).must_equal %{<span>Title:
|
18
|
+
<div>Still Knee Deep
|
19
|
+
</div>
|
20
|
+
</span>
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# form_tag { content_tag { } }
|
25
|
+
it( "xxx") do
|
26
|
+
form_tag = "<form action=\"/erubis/is/horribly/outdated\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" />"
|
27
|
+
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
|
28
|
+
|
29
|
+
input_tag = %{<input type="text" name="id" id="id" />}
|
30
|
+
input_tag = "<input id=\"id\" name=\"id\" type=\"text\" />" if ActionPack::VERSION::MAJOR == 3
|
31
|
+
|
32
|
+
form_with_body_tag = "<form url=\"/rails/escapes/too/much\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"button\"/></form>"
|
33
|
+
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
|
34
|
+
|
35
|
+
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\" />"
|
36
|
+
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
|
37
|
+
|
38
|
+
song_cell.(:with_form_tag_and_content_tag).must_equal %{Word.
|
39
|
+
#{form_tag}
|
40
|
+
#{input_tag}
|
41
|
+
<a href=\"/rails/sucks\">hallo
|
42
|
+
<div class='row'>
|
43
|
+
Cool
|
44
|
+
</div>
|
45
|
+
</a>
|
46
|
+
<ul>Hallo
|
47
|
+
</ul>
|
48
|
+
</form>
|
49
|
+
Weiter!
|
50
|
+
Bonjour!
|
51
|
+
<a href=\"/coffee\">Coffee?</a>
|
52
|
+
<b>Yes please!</b>
|
53
|
+
<script>oui!</script>
|
54
|
+
<a href=\"/1\">1</a>+<a href=\"/2\">2</a>
|
55
|
+
<b>No current page!<b>
|
56
|
+
#{form_with_body_tag}
|
57
|
+
#{form_for_tag}
|
58
|
+
</form>
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cells-hamlit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Abdelkader Boudih
|
8
|
+
- Nick Sutterer
|
9
|
+
- Timo Schilling
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: cells
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 4.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 4.0.0
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: hamlit
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: bundler
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
description: Hamlit integration for Cells
|
72
|
+
email:
|
73
|
+
- terminale@gmail.com
|
74
|
+
- apotonick@gmail.com
|
75
|
+
- timo@schilling.io
|
76
|
+
executables: []
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- ".gitignore"
|
81
|
+
- ".travis.yml"
|
82
|
+
- CHANGES.md
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- cells-hamlit.gemspec
|
88
|
+
- gemfiles/rails_3.2-tilt-1.4.gemfile
|
89
|
+
- gemfiles/rails_4.0-tilt-1.4.gemfile
|
90
|
+
- gemfiles/rails_4.2-tilt-1.4.gemfile
|
91
|
+
- gemfiles/rails_4.2-tilt-2.0.gemfile
|
92
|
+
- gemfiles/rails_4.2-tilt-3.0.gemfile
|
93
|
+
- lib/cell/hamlit.rb
|
94
|
+
- lib/cell/hamlit/version.rb
|
95
|
+
- lib/cells-hamlit.rb
|
96
|
+
- test/cell_generator_test.rb
|
97
|
+
- test/dummy/Rakefile
|
98
|
+
- test/dummy/app/cells/song/render_in_render.haml
|
99
|
+
- test/dummy/app/cells/song/render_in_render_2.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/dummy/log/test.log
|
114
|
+
- test/hamlit_test.rb
|
115
|
+
- test/test_helper.rb
|
116
|
+
homepage: https://github.com/trailblazer/cells-hamlit
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.4.8
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Hamlit integration for Cells
|
140
|
+
test_files:
|
141
|
+
- test/cell_generator_test.rb
|
142
|
+
- test/dummy/Rakefile
|
143
|
+
- test/dummy/app/cells/song/render_in_render.haml
|
144
|
+
- test/dummy/app/cells/song/render_in_render_2.haml
|
145
|
+
- test/dummy/app/cells/song/with_content_tag.haml
|
146
|
+
- test/dummy/app/cells/song/with_content_tag_and_content_tag.haml
|
147
|
+
- test/dummy/app/cells/song/with_form_tag_and_content_tag.haml
|
148
|
+
- test/dummy/app/cells/song_cell.rb
|
149
|
+
- test/dummy/app/controllers/application_controller.rb
|
150
|
+
- test/dummy/config.ru
|
151
|
+
- test/dummy/config/application.rb
|
152
|
+
- test/dummy/config/boot.rb
|
153
|
+
- test/dummy/config/database.yml
|
154
|
+
- test/dummy/config/environment.rb
|
155
|
+
- test/dummy/config/initializers/cells.rb
|
156
|
+
- test/dummy/config/locales/en.yml
|
157
|
+
- test/dummy/config/routes.rb
|
158
|
+
- test/dummy/log/test.log
|
159
|
+
- test/hamlit_test.rb
|
160
|
+
- test/test_helper.rb
|
161
|
+
has_rdoc:
|