cells-haml 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +11 -0
- data/cells-haml.gemspec +23 -0
- data/lib/cell/haml.rb +89 -0
- data/lib/cells/haml.rb +1 -0
- data/test/cell_generator_test.rb +39 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +2 -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/config.ru +4 -0
- data/test/haml_test.rb +7 -0
- data/test/test_helper.rb +13 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f1fff5928a0a320599bd5fa9a1cf5bd7188e5110
|
4
|
+
data.tar.gz: b18d5b39e8b5da0815fe0b2d2a975a2f86673d1f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 659f4e915f806adb3dffc4e8e5a1b93ea10f1ec99b7163a0e5211c7522a11a15e1c0c5424f25855405948125f47d8cfecf97b3bf2ae764e68021e161aeb7bf33
|
7
|
+
data.tar.gz: 563e408aa0e04a5f652850016a7791356ae25a787dc5e76a0bd167993590445259cde1126fc58c60096d169449921e8f83b168bd3b981e2833da11d727f00ec5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in cells-haml.gemspec
|
4
|
+
gemspec
|
5
|
+
platforms :mri_20, :mri_21 do
|
6
|
+
gem 'pry-byebug'
|
7
|
+
end
|
8
|
+
gem 'cells', github: 'apotonick/cells'
|
9
|
+
gem 'railties'
|
10
|
+
gem 'actionpack'
|
11
|
+
gem 'actionview'
|
12
|
+
gem 'appraisal'
|
13
|
+
gem 'minitest-reporters'
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014-2015 Abdelkader Boudih & Nick Sutterer
|
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,31 @@
|
|
1
|
+
# Cells::Haml
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cells-haml'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cells-haml
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/trailblazer/cells-haml/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/cells-haml.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'cells-haml'
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ['Abdelkader Boudih', 'Nick Sutterer']
|
9
|
+
spec.email = %w(terminale@gmail.com apotonick@gmail.com)
|
10
|
+
spec.summary = 'Haml integration for Cells'
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = 'https://github.com/trailblazer/cells-haml'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test)/})
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_runtime_dependency 'cells', '~> 4.0.0.beta'
|
20
|
+
spec.add_runtime_dependency 'haml', '~> 4.0'
|
21
|
+
spec.add_development_dependency 'bundler', '>= 1.6'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
end
|
data/lib/cell/haml.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'cells'
|
2
|
+
require 'tilt/haml'
|
3
|
+
|
4
|
+
module Cell
|
5
|
+
module Haml
|
6
|
+
def output_buffer_with_haml
|
7
|
+
return haml_buffer.buffer if is_haml?
|
8
|
+
output_buffer_without_haml
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_output_buffer_with_haml(new_buffer)
|
12
|
+
if is_haml?
|
13
|
+
if ::Haml::Util.rails_xss_safe? && new_buffer.is_a?(ActiveSupport::SafeBuffer)
|
14
|
+
new_buffer = String.new(new_buffer)
|
15
|
+
end
|
16
|
+
haml_buffer.buffer = new_buffer
|
17
|
+
else
|
18
|
+
set_output_buffer_without_haml new_buffer
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def self.included(base)
|
24
|
+
base.class_eval do
|
25
|
+
alias_method :output_buffer_without_haml, :output_buffer
|
26
|
+
alias_method :output_buffer, :output_buffer_with_haml
|
27
|
+
|
28
|
+
alias_method :set_output_buffer_without_haml, :output_buffer=
|
29
|
+
alias_method :output_buffer=, :set_output_buffer_with_haml
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# TODO: remove the concept of output buffers and just return block's result!
|
34
|
+
class OutputBuffer < String
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def with_output_buffer(buf = nil)
|
39
|
+
unless buf
|
40
|
+
buf = OutputBuffer.new
|
41
|
+
end
|
42
|
+
self.output_buffer, old_buffer = buf, output_buffer
|
43
|
+
yield
|
44
|
+
output_buffer
|
45
|
+
ensure
|
46
|
+
self.output_buffer = old_buffer
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
# generic ERB HAML HELPERS>>>>>>
|
51
|
+
def capture(*args,&block)
|
52
|
+
value = nil
|
53
|
+
buffer = with_output_buffer() { value = yield(*args) }
|
54
|
+
if string = buffer.presence || value and string.is_a?(String)
|
55
|
+
return string
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# From FormTagHelper. why do they escape every possible string? why?
|
60
|
+
def form_tag_in_block(html_options, &block)
|
61
|
+
content = capture(&block)
|
62
|
+
form_tag_with_body(html_options, content)
|
63
|
+
end
|
64
|
+
|
65
|
+
def form_tag_with_body(html_options, content)
|
66
|
+
"#{form_tag_html(html_options)}" << content.to_s << "</form>"
|
67
|
+
end
|
68
|
+
|
69
|
+
def form_tag_html(html_options)
|
70
|
+
extra_tags = extra_tags_for_form(html_options)
|
71
|
+
"#{tag(:form, html_options, true) + extra_tags}"
|
72
|
+
end
|
73
|
+
|
74
|
+
# Rails 4.0, TagHelper.
|
75
|
+
def tag_option(key, value, escape)
|
76
|
+
super(key, value, false)
|
77
|
+
end
|
78
|
+
|
79
|
+
def content_tag_string(name, content, options, escape=true)
|
80
|
+
super(name, content, options, false)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
ViewModel.class_eval do
|
85
|
+
include Haml
|
86
|
+
end
|
87
|
+
|
88
|
+
ViewModel.template_engine = :haml
|
89
|
+
end
|
data/lib/cells/haml.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'cell/haml'
|
@@ -0,0 +1,39 @@
|
|
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
|
+
run_generator %w(blog post latest)
|
12
|
+
|
13
|
+
assert_file 'app/cells/blog_cell.rb', /class BlogCell < Cell::ViewModel/
|
14
|
+
assert_file 'app/cells/blog_cell.rb', /def post/
|
15
|
+
assert_file 'app/cells/blog_cell.rb', /def latest/
|
16
|
+
assert_file 'app/cells/blog/post.haml', %r{app/cells/blog/post\.haml}
|
17
|
+
assert_file 'app/cells/blog/post.haml', %r{<p>}
|
18
|
+
assert_file 'app/cells/blog/latest.haml', %r{app/cells/blog/latest\.haml}
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'create cell that inherits from custom cell class if specified' do
|
22
|
+
run_generator %w(Blog --parent=ApplicationCell)
|
23
|
+
assert_file 'app/cells/blog_cell.rb', /class BlogCell < ApplicationCell/
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'work with namespaces' do
|
27
|
+
run_generator %w(blog/post latest)
|
28
|
+
assert_file 'app/cells/blog/post_cell.rb', /class Blog::PostCell < Cell::ViewModel/
|
29
|
+
assert_file 'app/cells/blog/post_cell.rb', /def show/
|
30
|
+
assert_file 'app/cells/blog/post_cell.rb', /def latest/
|
31
|
+
assert_file 'app/cells/blog/post/latest.haml', %r{app/cells/blog/post/latest\.haml}
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'work with namespaces and haml' do
|
35
|
+
run_generator %w(blog/post latest)
|
36
|
+
assert_file 'app/cells/blog/post_cell.rb', /class Blog::PostCell < Cell::ViewModel/
|
37
|
+
assert_file 'app/cells/blog/post/latest.haml', %r{app/cells/blog/post/latest\.haml}
|
38
|
+
end
|
39
|
+
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,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/haml_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
begin
|
2
|
+
require 'byebug'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
require 'minitest/reporters'
|
6
|
+
Minitest::Reporters.use! [Minitest::Reporters::ProgressReporter.new]
|
7
|
+
require 'minitest/autorun'
|
8
|
+
|
9
|
+
ENV['RAILS_ENV'] = 'test'
|
10
|
+
|
11
|
+
require 'cells'
|
12
|
+
require_relative 'dummy/config/environment'
|
13
|
+
require 'cell/haml'
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cells-haml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Abdelkader Boudih
|
8
|
+
- Nick Sutterer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-02-13 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.0.beta
|
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.0.beta
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: haml
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '4.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '4.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: '1.6'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.6'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
description: Haml integration for Cells
|
71
|
+
email:
|
72
|
+
- terminale@gmail.com
|
73
|
+
- apotonick@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- cells-haml.gemspec
|
84
|
+
- lib/cell/haml.rb
|
85
|
+
- lib/cells/haml.rb
|
86
|
+
- test/cell_generator_test.rb
|
87
|
+
- test/dummy/Rakefile
|
88
|
+
- test/dummy/app/controllers/application_controller.rb
|
89
|
+
- test/dummy/config.ru
|
90
|
+
- test/dummy/config/application.rb
|
91
|
+
- test/dummy/config/boot.rb
|
92
|
+
- test/dummy/config/database.yml
|
93
|
+
- test/dummy/config/environment.rb
|
94
|
+
- test/dummy/config/initializers/cells.rb
|
95
|
+
- test/dummy/config/locales/en.yml
|
96
|
+
- test/dummy/config/routes.rb
|
97
|
+
- test/haml_test.rb
|
98
|
+
- test/test_helper.rb
|
99
|
+
homepage: https://github.com/trailblazer/cells-haml
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.4.5
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Haml integration for Cells
|
123
|
+
test_files:
|
124
|
+
- test/cell_generator_test.rb
|
125
|
+
- test/dummy/Rakefile
|
126
|
+
- test/dummy/app/controllers/application_controller.rb
|
127
|
+
- test/dummy/config.ru
|
128
|
+
- test/dummy/config/application.rb
|
129
|
+
- test/dummy/config/boot.rb
|
130
|
+
- test/dummy/config/database.yml
|
131
|
+
- test/dummy/config/environment.rb
|
132
|
+
- test/dummy/config/initializers/cells.rb
|
133
|
+
- test/dummy/config/locales/en.yml
|
134
|
+
- test/dummy/config/routes.rb
|
135
|
+
- test/haml_test.rb
|
136
|
+
- test/test_helper.rb
|
137
|
+
has_rdoc:
|