mega-quick-lib 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/mega-quick-lib.gemspec +12 -0
- data/slim-5.2.1/CHANGES +496 -0
- data/slim-5.2.1/Gemfile +43 -0
- data/slim-5.2.1/LICENSE +21 -0
- data/slim-5.2.1/README.jp.md +1276 -0
- data/slim-5.2.1/README.md +1313 -0
- data/slim-5.2.1/Rakefile +80 -0
- data/slim-5.2.1/bin/slimrb +6 -0
- data/slim-5.2.1/doc/include.md +20 -0
- data/slim-5.2.1/doc/jp/include.md +20 -0
- data/slim-5.2.1/doc/jp/logic_less.md +137 -0
- data/slim-5.2.1/doc/jp/smart.md +102 -0
- data/slim-5.2.1/doc/jp/translator.md +28 -0
- data/slim-5.2.1/doc/logic_less.md +137 -0
- data/slim-5.2.1/doc/smart.md +120 -0
- data/slim-5.2.1/doc/translator.md +28 -0
- data/slim-5.2.1/lib/slim/code_attributes.rb +68 -0
- data/slim-5.2.1/lib/slim/command.rb +122 -0
- data/slim-5.2.1/lib/slim/controls.rb +61 -0
- data/slim-5.2.1/lib/slim/do_inserter.rb +34 -0
- data/slim-5.2.1/lib/slim/embedded.rb +248 -0
- data/slim-5.2.1/lib/slim/end_inserter.rb +63 -0
- data/slim-5.2.1/lib/slim/engine.rb +42 -0
- data/slim-5.2.1/lib/slim/erb_converter.rb +15 -0
- data/slim-5.2.1/lib/slim/filter.rb +31 -0
- data/slim-5.2.1/lib/slim/grammar.rb +24 -0
- data/slim-5.2.1/lib/slim/include.rb +58 -0
- data/slim-5.2.1/lib/slim/interpolation.rb +36 -0
- data/slim-5.2.1/lib/slim/logic_less/context.rb +126 -0
- data/slim-5.2.1/lib/slim/logic_less/filter.rb +81 -0
- data/slim-5.2.1/lib/slim/logic_less.rb +6 -0
- data/slim-5.2.1/lib/slim/parser.rb +535 -0
- data/slim-5.2.1/lib/slim/railtie.rb +19 -0
- data/slim-5.2.1/lib/slim/smart/escaper.rb +42 -0
- data/slim-5.2.1/lib/slim/smart/filter.rb +97 -0
- data/slim-5.2.1/lib/slim/smart/parser.rb +35 -0
- data/slim-5.2.1/lib/slim/smart.rb +9 -0
- data/slim-5.2.1/lib/slim/splat/builder.rb +115 -0
- data/slim-5.2.1/lib/slim/splat/filter.rb +93 -0
- data/slim-5.2.1/lib/slim/template.rb +6 -0
- data/slim-5.2.1/lib/slim/translator.rb +119 -0
- data/slim-5.2.1/lib/slim/version.rb +6 -0
- data/slim-5.2.1/lib/slim.rb +16 -0
- data/slim-5.2.1/slim.gemspec +33 -0
- data/slim-5.2.1/test/core/helper.rb +201 -0
- data/slim-5.2.1/test/core/test_code_blocks.rb +194 -0
- data/slim-5.2.1/test/core/test_code_escaping.rb +162 -0
- data/slim-5.2.1/test/core/test_code_evaluation.rb +181 -0
- data/slim-5.2.1/test/core/test_code_output.rb +168 -0
- data/slim-5.2.1/test/core/test_code_structure.rb +203 -0
- data/slim-5.2.1/test/core/test_commands.rb +219 -0
- data/slim-5.2.1/test/core/test_embedded_engines.rb +247 -0
- data/slim-5.2.1/test/core/test_encoding.rb +28 -0
- data/slim-5.2.1/test/core/test_erb_converter.rb +65 -0
- data/slim-5.2.1/test/core/test_html_attributes.rb +276 -0
- data/slim-5.2.1/test/core/test_html_escaping.rb +65 -0
- data/slim-5.2.1/test/core/test_html_structure.rb +599 -0
- data/slim-5.2.1/test/core/test_parser_errors.rb +148 -0
- data/slim-5.2.1/test/core/test_pretty.rb +163 -0
- data/slim-5.2.1/test/core/test_ruby_errors.rb +200 -0
- data/slim-5.2.1/test/core/test_slim_template.rb +78 -0
- data/slim-5.2.1/test/core/test_splat_prefix_option.rb +155 -0
- data/slim-5.2.1/test/core/test_tabs.rb +169 -0
- data/slim-5.2.1/test/core/test_text_interpolation.rb +79 -0
- data/slim-5.2.1/test/core/test_thread_options.rb +18 -0
- data/slim-5.2.1/test/core/test_unicode.rb +15 -0
- data/slim-5.2.1/test/include/files/recursive.slim +1 -0
- data/slim-5.2.1/test/include/files/slimfile.slim +3 -0
- data/slim-5.2.1/test/include/files/subdir/test.slim +1 -0
- data/slim-5.2.1/test/include/files/textfile +1 -0
- data/slim-5.2.1/test/include/test_include.rb +24 -0
- data/slim-5.2.1/test/literate/TESTS.md +1323 -0
- data/slim-5.2.1/test/literate/helper.rb +15 -0
- data/slim-5.2.1/test/literate/run.rb +92 -0
- data/slim-5.2.1/test/logic_less/test_logic_less.rb +330 -0
- data/slim-5.2.1/test/rails/Rakefile +7 -0
- data/slim-5.2.1/test/rails/app/assets/config/manifest.js +1 -0
- data/slim-5.2.1/test/rails/app/controllers/application_controller.rb +2 -0
- data/slim-5.2.1/test/rails/app/controllers/entries_controller.rb +5 -0
- data/slim-5.2.1/test/rails/app/controllers/slim_controller.rb +46 -0
- data/slim-5.2.1/test/rails/app/helpers/application_helper.rb +5 -0
- data/slim-5.2.1/test/rails/app/models/entry.rb +16 -0
- data/slim-5.2.1/test/rails/app/views/entries/edit.html.slim +3 -0
- data/slim-5.2.1/test/rails/app/views/layouts/application.html+testvariant.slim +10 -0
- data/slim-5.2.1/test/rails/app/views/layouts/application.html.slim +10 -0
- data/slim-5.2.1/test/rails/app/views/slim/_partial.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/attributes.html.slim +3 -0
- data/slim-5.2.1/test/rails/app/views/slim/content_for.html.slim +7 -0
- data/slim-5.2.1/test/rails/app/views/slim/erb.html.erb +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/form_for.html.slim +2 -0
- data/slim-5.2.1/test/rails/app/views/slim/helper.html.slim +4 -0
- data/slim-5.2.1/test/rails/app/views/slim/integers.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/no_layout.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/normal.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/partial.html.slim +2 -0
- data/slim-5.2.1/test/rails/app/views/slim/splat.html.slim +2 -0
- data/slim-5.2.1/test/rails/app/views/slim/splat_with_delimiter.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/thread_options.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/variables.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/xml.slim +1 -0
- data/slim-5.2.1/test/rails/config/application.rb +44 -0
- data/slim-5.2.1/test/rails/config/boot.rb +10 -0
- data/slim-5.2.1/test/rails/config/environment.rb +5 -0
- data/slim-5.2.1/test/rails/config/environments/test.rb +34 -0
- data/slim-5.2.1/test/rails/config/initializers/backtrace_silencers.rb +7 -0
- data/slim-5.2.1/test/rails/config/initializers/inflections.rb +10 -0
- data/slim-5.2.1/test/rails/config/initializers/mime_types.rb +5 -0
- data/slim-5.2.1/test/rails/config/initializers/session_store.rb +8 -0
- data/slim-5.2.1/test/rails/config/locales/en.yml +5 -0
- data/slim-5.2.1/test/rails/config/routes.rb +60 -0
- data/slim-5.2.1/test/rails/config.ru +4 -0
- data/slim-5.2.1/test/rails/script/rails +6 -0
- data/slim-5.2.1/test/rails/test/helper.rb +34 -0
- data/slim-5.2.1/test/rails/test/test_slim.rb +102 -0
- data/slim-5.2.1/test/sinatra/contest.rb +91 -0
- data/slim-5.2.1/test/sinatra/helper.rb +143 -0
- data/slim-5.2.1/test/sinatra/test_core.rb +91 -0
- data/slim-5.2.1/test/sinatra/test_include.rb +16 -0
- data/slim-5.2.1/test/sinatra/views/embed_include_js.slim +8 -0
- data/slim-5.2.1/test/sinatra/views/embed_js.slim +11 -0
- data/slim-5.2.1/test/sinatra/views/footer.slim +1 -0
- data/slim-5.2.1/test/sinatra/views/hello.slim +1 -0
- data/slim-5.2.1/test/sinatra/views/layout2.slim +3 -0
- data/slim-5.2.1/test/smart/test_smart_text.rb +294 -0
- data/slim-5.2.1/test/translator/test_translator.rb +76 -0
- metadata +166 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'slim'
|
|
2
|
+
require 'slim/logic_less'
|
|
3
|
+
require 'slim/translator'
|
|
4
|
+
require 'slim/grammar'
|
|
5
|
+
require 'minitest/autorun'
|
|
6
|
+
|
|
7
|
+
Slim::Engine.after Slim::Parser, Temple::Filters::Validator, grammar: Slim::Grammar
|
|
8
|
+
Slim::Engine.before :Pretty, Temple::Filters::Validator
|
|
9
|
+
Slim::Engine.set_options tr: false, logic_less: false
|
|
10
|
+
|
|
11
|
+
class Minitest::Spec
|
|
12
|
+
def render(source, options = {}, &block)
|
|
13
|
+
Slim::Template.new(options) { source }.render(self, &block)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'temple'
|
|
2
|
+
|
|
3
|
+
class LiterateTest < Temple::Engine
|
|
4
|
+
class Parser < Temple::Parser
|
|
5
|
+
def call(lines)
|
|
6
|
+
stack = [[:multi]]
|
|
7
|
+
until lines.empty?
|
|
8
|
+
case lines.shift
|
|
9
|
+
when /\A(#+)\s*(.*)\Z/
|
|
10
|
+
stack.pop(stack.size - $1.size)
|
|
11
|
+
block = [:multi]
|
|
12
|
+
stack.last << [:section, $2, block]
|
|
13
|
+
stack << block
|
|
14
|
+
when /\A~{3,}\s*(\w+)\s*\Z/
|
|
15
|
+
lang = $1
|
|
16
|
+
code = []
|
|
17
|
+
until lines.empty?
|
|
18
|
+
case lines.shift
|
|
19
|
+
when /\A~{3,}\s*\Z/
|
|
20
|
+
break
|
|
21
|
+
when /\A.*\Z/
|
|
22
|
+
code << $&
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
stack.last << [lang.to_sym, code.join("\n")]
|
|
26
|
+
when /\A\s*\Z/
|
|
27
|
+
when /\A\s*(.*?)\s*Z/
|
|
28
|
+
stack.last << [:comment, $1]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
stack.first
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class Compiler < Temple::Filter
|
|
36
|
+
def call(exp)
|
|
37
|
+
@opts, @in_testcase = {}, false
|
|
38
|
+
"require 'helper'\n\n#{compile(exp)}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def on_section(title, body)
|
|
42
|
+
old_opts = @opts.dup
|
|
43
|
+
raise Temple::FilterError, 'New section between slim and html block' if @in_testcase
|
|
44
|
+
"describe #{title.inspect} do\n #{compile(body).gsub("\n", "\n ")}\nend\n"
|
|
45
|
+
ensure
|
|
46
|
+
@opts = old_opts
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def on_multi(*exps)
|
|
50
|
+
exps.map {|exp| compile(exp) }.join("\n")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def on_comment(text)
|
|
54
|
+
"#{@in_testcase ? ' ' : ''}# #{text}"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def on_slim(code)
|
|
58
|
+
raise Temple::FilterError, 'Slim block must be followed by html block' if @in_testcase
|
|
59
|
+
@in_testcase = true
|
|
60
|
+
"it 'should render' do\n slim = #{code.inspect}"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def on_html(code)
|
|
64
|
+
raise Temple::FilterError, 'Html block must be preceded by slim block' unless @in_testcase
|
|
65
|
+
@in_testcase = false
|
|
66
|
+
result = " html = #{code.inspect}\n".dup
|
|
67
|
+
if @opts.empty?
|
|
68
|
+
result << " _(render(slim)).must_equal html\nend\n"
|
|
69
|
+
else
|
|
70
|
+
result << " options = #{@opts.inspect}\n _(render(slim, options)).must_equal html\nend\n"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def on_options(code)
|
|
75
|
+
raise Temple::FilterError, 'Options set inside test case' if @in_testcase
|
|
76
|
+
@opts.update(eval("{#{code}}"))
|
|
77
|
+
"# #{code.gsub("\n", "\n# ")}"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def on(*exp)
|
|
81
|
+
raise Temple::InvalidExpression, exp
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
use Parser
|
|
86
|
+
use Compiler
|
|
87
|
+
use(:Evaluator) {|code| eval(code) }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
Dir.glob(File.join(File.dirname(__FILE__), '*.md')) do |file|
|
|
91
|
+
LiterateTest.new.call(File.readlines(file))
|
|
92
|
+
end
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
require 'slim/logic_less'
|
|
3
|
+
|
|
4
|
+
class TestSlimLogicLess < TestSlim
|
|
5
|
+
class Scope
|
|
6
|
+
def initialize
|
|
7
|
+
@hash = {
|
|
8
|
+
person: [
|
|
9
|
+
{ name: 'Joe', age: 1, selected: true },
|
|
10
|
+
{ name: 'Jack', age: 2 }
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_lambda
|
|
17
|
+
source = %q{
|
|
18
|
+
p
|
|
19
|
+
== person
|
|
20
|
+
.name = name
|
|
21
|
+
== simple
|
|
22
|
+
.hello= hello
|
|
23
|
+
== list
|
|
24
|
+
li = key
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
hash = {
|
|
28
|
+
hello: 'Hello!',
|
|
29
|
+
person: lambda do |&block|
|
|
30
|
+
%w(Joe Jack).map do |name|
|
|
31
|
+
"<b>#{block.call(name: name)}</b>"
|
|
32
|
+
end.join
|
|
33
|
+
end,
|
|
34
|
+
simple: lambda do |&block|
|
|
35
|
+
"<div class=\"simple\">#{block.call}</div>"
|
|
36
|
+
end,
|
|
37
|
+
list: lambda do |&block|
|
|
38
|
+
list = [{key: 'First'}, {key: 'Second'}]
|
|
39
|
+
"<ul>#{block.call(*list)}</ul>"
|
|
40
|
+
end
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
assert_html '<p><b><div class="name">Joe</div></b><b><div class="name">Jack</div></b><div class="simple"><div class="hello">Hello!</div></div><ul><li>First</li><li>Second</li></ul></p>', source, scope: hash
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_symbol_hash
|
|
47
|
+
source = %q{
|
|
48
|
+
p
|
|
49
|
+
- person
|
|
50
|
+
.name = name
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
hash = {
|
|
54
|
+
person: [
|
|
55
|
+
{ name: 'Joe', },
|
|
56
|
+
{ name: 'Jack', }
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: hash
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_string_access
|
|
64
|
+
source = %q{
|
|
65
|
+
p
|
|
66
|
+
- person
|
|
67
|
+
.name = name
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
hash = {
|
|
71
|
+
'person' => [
|
|
72
|
+
{ 'name' => 'Joe', },
|
|
73
|
+
{ 'name' => 'Jack', }
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: hash, dictionary_access: :string
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_symbol_access
|
|
81
|
+
source = %q{
|
|
82
|
+
p
|
|
83
|
+
- person
|
|
84
|
+
.name = name
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
hash = {
|
|
88
|
+
person: [
|
|
89
|
+
{ name: 'Joe', },
|
|
90
|
+
{ name: 'Jack', }
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: hash, dictionary_access: :symbol
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_method_access
|
|
98
|
+
source = %q{
|
|
99
|
+
p
|
|
100
|
+
- person
|
|
101
|
+
.name = name
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
object = Object.new
|
|
105
|
+
def object.person
|
|
106
|
+
%w(Joe Jack).map do |name|
|
|
107
|
+
person = Object.new
|
|
108
|
+
person.instance_variable_set(:@name, name)
|
|
109
|
+
def person.name
|
|
110
|
+
@name
|
|
111
|
+
end
|
|
112
|
+
person
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: object, dictionary_access: :method
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_method_access_without_private
|
|
120
|
+
source = %q{
|
|
121
|
+
p
|
|
122
|
+
- person
|
|
123
|
+
.age = age
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
object = Object.new
|
|
127
|
+
def object.person
|
|
128
|
+
person = Object.new
|
|
129
|
+
def person.age
|
|
130
|
+
42
|
|
131
|
+
end
|
|
132
|
+
person.singleton_class.class_eval { private :age }
|
|
133
|
+
person
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
assert_html '<p><div class="age"></div></p>', source, scope: object, dictionary_access: :method
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def test_instance_variable_access
|
|
140
|
+
source = %q{
|
|
141
|
+
p
|
|
142
|
+
- person
|
|
143
|
+
.name = name
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
object = Object.new
|
|
147
|
+
object.instance_variable_set(:@person, %w(Joe Jack).map do |name|
|
|
148
|
+
person = Object.new
|
|
149
|
+
person.instance_variable_set(:@name, name)
|
|
150
|
+
person
|
|
151
|
+
end)
|
|
152
|
+
|
|
153
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: object, dictionary_access: :instance_variable
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_to_s_access
|
|
157
|
+
source = %q{
|
|
158
|
+
p
|
|
159
|
+
- people
|
|
160
|
+
.name = self
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
hash = {
|
|
164
|
+
people: [
|
|
165
|
+
'Joe',
|
|
166
|
+
'Jack'
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: hash, dictionary_access: :symbol
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_string_hash
|
|
174
|
+
source = %q{
|
|
175
|
+
p
|
|
176
|
+
- person
|
|
177
|
+
.name = name
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
hash = {
|
|
181
|
+
'person' => [
|
|
182
|
+
{ 'name' => 'Joe', },
|
|
183
|
+
{ 'name' => 'Jack', }
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: hash
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def test_dictionary_option
|
|
191
|
+
source = %q{
|
|
192
|
+
p
|
|
193
|
+
- person
|
|
194
|
+
.name = name
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, scope: Scope.new, dictionary: '@hash'
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def test_flag_section
|
|
201
|
+
source = %q{
|
|
202
|
+
p
|
|
203
|
+
- show_person
|
|
204
|
+
- person
|
|
205
|
+
.name = name
|
|
206
|
+
- show_person
|
|
207
|
+
| shown
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
hash = {
|
|
211
|
+
show_person: true,
|
|
212
|
+
person: [
|
|
213
|
+
{ name: 'Joe', },
|
|
214
|
+
{ name: 'Jack', }
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div>shown</p>', source, scope: hash
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def test_inverted_section
|
|
222
|
+
source = %q{
|
|
223
|
+
p
|
|
224
|
+
- person
|
|
225
|
+
.name = name
|
|
226
|
+
-! person
|
|
227
|
+
| No person
|
|
228
|
+
- !person
|
|
229
|
+
| No person 2
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
hash = {}
|
|
233
|
+
|
|
234
|
+
assert_html '<p>No person No person 2</p>', source, scope: hash
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def test_escaped_interpolation
|
|
238
|
+
source = %q{
|
|
239
|
+
p text with \#{123} test
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
assert_html '<p>text with #{123} test</p>', source
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def test_ruby_attributes
|
|
246
|
+
source = %q{
|
|
247
|
+
p
|
|
248
|
+
- person
|
|
249
|
+
b name=name Person
|
|
250
|
+
a id=name = age
|
|
251
|
+
span class=name
|
|
252
|
+
Person
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
assert_html '<p><b name="Joe">Person</b><a id="Joe">1</a><span class="Joe"><Person></Person></span><b name="Jack">Person</b><a id="Jack">2</a><span class="Jack"><Person></Person></span></p>', source, scope: Scope.new, dictionary: '@hash'
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def test_boolean_attributes
|
|
259
|
+
source = %q{
|
|
260
|
+
p
|
|
261
|
+
- person
|
|
262
|
+
input checked=selected = name
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
assert_html '<p><input checked="">Joe</input><input>Jack</input></p>', source, scope: Scope.new, dictionary: '@hash'
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def test_sections
|
|
269
|
+
source = %q{
|
|
270
|
+
p
|
|
271
|
+
- person
|
|
272
|
+
.name = name
|
|
273
|
+
}
|
|
274
|
+
assert_html '<p><div class="name">Joe</div><div class="name">Jack</div></p>', source, dictionary: 'ViewEnv.new'
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def test_with_array
|
|
278
|
+
source = %q{
|
|
279
|
+
ul
|
|
280
|
+
- people_with_locations
|
|
281
|
+
li = name
|
|
282
|
+
li = city
|
|
283
|
+
}
|
|
284
|
+
assert_html '<ul><li>Andy</li><li>Atlanta</li><li>Fred</li><li>Melbourne</li><li>Daniel</li><li>Karlsruhe</li></ul>', source, dictionary: 'ViewEnv.new'
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def test_method
|
|
288
|
+
source = %q{
|
|
289
|
+
a href=output_number Link
|
|
290
|
+
}
|
|
291
|
+
assert_html '<a href="1337">Link</a>', source, dictionary: 'ViewEnv.new'
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def test_conditional_parent
|
|
295
|
+
source = %q{
|
|
296
|
+
- prev_page
|
|
297
|
+
li.previous
|
|
298
|
+
a href=prev_page Older
|
|
299
|
+
- next_page
|
|
300
|
+
li.next
|
|
301
|
+
a href=next_page Newer}
|
|
302
|
+
assert_html'<li class="previous"><a href="prev">Older</a></li><li class="next"><a href="next">Newer</a></li>', source, scope: {prev_page: 'prev', next_page: 'next'}
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def test_render_with_yield
|
|
306
|
+
source = %q{
|
|
307
|
+
div
|
|
308
|
+
== yield
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
assert_html '<div>This is the menu</div>', source do
|
|
312
|
+
'This is the menu'
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def test_render_parent_lambda
|
|
317
|
+
source = %q{
|
|
318
|
+
- list
|
|
319
|
+
== fn
|
|
320
|
+
p = string
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
assert_html '<fn><p>str</p></fn><fn><p>str</p></fn><fn><p>str</p></fn>',
|
|
324
|
+
source, scope: {
|
|
325
|
+
fn: ->(&block) { "<fn>#{block.call}</fn>" },
|
|
326
|
+
list: [ "item1", "item2", "item3" ],
|
|
327
|
+
string: "str"
|
|
328
|
+
}
|
|
329
|
+
end
|
|
330
|
+
end
|
|
@@ -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
|
+
// file required by sprockets >= 4.0
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class SlimController < ApplicationController
|
|
2
|
+
def normal
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
def xml
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def no_layout
|
|
9
|
+
render layout: false
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def variables
|
|
13
|
+
@hello = "Hello Slim with variables!"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def partial
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def streaming
|
|
20
|
+
@hello = "Hello Streaming!"
|
|
21
|
+
render :content_for, stream: true
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def integers
|
|
25
|
+
@integer = 1337
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def thread_options
|
|
29
|
+
default_shortcut = {'#' => {attr: 'id'}, '.' => {attr: 'class'} }
|
|
30
|
+
Slim::Engine.with_options(shortcut: default_shortcut.merge({'@' => { attr: params[:attr] }})) do
|
|
31
|
+
render
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def variant
|
|
36
|
+
request.variant = :testvariant
|
|
37
|
+
render :normal
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def content_for
|
|
41
|
+
@hello = "Hello Slim!"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def helper
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Entry
|
|
2
|
+
include ActiveModel::Conversion
|
|
3
|
+
extend ActiveModel::Naming
|
|
4
|
+
|
|
5
|
+
attr_accessor :name
|
|
6
|
+
|
|
7
|
+
def initialize(attributes = {})
|
|
8
|
+
attributes.each do |name, value|
|
|
9
|
+
send("#{name}=", value)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def persisted?
|
|
14
|
+
false
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
p With a partial!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Hello Erb!</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
p= @integer
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
h1 Hello Slim without a layout!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
h1 Hello Slim!
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.cute *{class: "nice"} Hello
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
p@empty Test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
h1= @hello
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
h1 Hello Slim!
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'active_model/railtie'
|
|
4
|
+
require 'action_controller/railtie'
|
|
5
|
+
require 'action_view/railtie'
|
|
6
|
+
#require 'active_record/railtie'
|
|
7
|
+
#require 'action_mailer/railtie'
|
|
8
|
+
#require 'sprockets/railtie'
|
|
9
|
+
require 'slim'
|
|
10
|
+
|
|
11
|
+
module Dummy
|
|
12
|
+
class Application < Rails::Application
|
|
13
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
14
|
+
# Application configuration should go into files in config/initializers
|
|
15
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
16
|
+
|
|
17
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
18
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
|
19
|
+
|
|
20
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
21
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
22
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
23
|
+
|
|
24
|
+
# Activate observers that should always be running.
|
|
25
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
26
|
+
|
|
27
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
28
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
29
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
30
|
+
|
|
31
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
32
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
33
|
+
# config.i18n.default_locale = :de
|
|
34
|
+
|
|
35
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
|
36
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
|
37
|
+
|
|
38
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
39
|
+
config.encoding = "utf-8"
|
|
40
|
+
|
|
41
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
42
|
+
config.filter_parameters += [:password]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
gemfile = File.expand_path('../../../../../../Gemfile', __FILE__)
|
|
3
|
+
|
|
4
|
+
if File.exist?(gemfile)
|
|
5
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
|
6
|
+
require 'bundler'
|
|
7
|
+
Bundler.setup(:default, :integration)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
$:.unshift File.expand_path('../../../../../../lib', __FILE__)
|