mab 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +5 -1
- data/Gemfile.lock +3 -3
- data/Rakefile +10 -2
- data/lib/mab.rb +1 -0
- data/lib/mab/indentation.rb +2 -2
- data/lib/mab/mixin.rb +57 -57
- data/lib/mab/rails.rb +20 -0
- data/lib/mab/version.rb +1 -1
- data/test/rails/Rakefile +7 -0
- data/test/rails/app/assets/images/rails.png +0 -0
- data/test/rails/app/assets/javascripts/application.js +15 -0
- data/test/rails/app/assets/stylesheets/application.css +13 -0
- data/test/rails/app/controllers/application_controller.rb +17 -0
- data/test/rails/app/helpers/application_helper.rb +2 -0
- data/test/rails/app/views/application/content_for.html.mab +6 -0
- data/test/rails/app/views/application/normal.html.mab +2 -0
- data/test/rails/app/views/application/variables.html.mab +2 -0
- data/test/rails/app/views/layouts/application.html.mab +15 -0
- data/test/rails/config.ru +4 -0
- data/test/rails/config/application.rb +54 -0
- data/test/rails/config/boot.rb +6 -0
- data/test/rails/config/environment.rb +5 -0
- data/test/rails/config/environments/development.rb +27 -0
- data/test/rails/config/environments/production.rb +67 -0
- data/test/rails/config/environments/test.rb +29 -0
- data/test/rails/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails/config/initializers/inflections.rb +15 -0
- data/test/rails/config/initializers/mime_types.rb +5 -0
- data/test/rails/config/initializers/secret_token.rb +7 -0
- data/test/rails/config/initializers/session_store.rb +8 -0
- data/test/rails/config/initializers/wrap_parameters.rb +14 -0
- data/test/rails/config/locales/en.yml +5 -0
- data/test/rails/config/routes.rb +3 -0
- data/test/rails/script/rails +6 -0
- data/test/rails/test/helper.rb +7 -0
- data/test/rails/test/test_mab.rb +40 -0
- data/test/test_mab_mixin.rb +10 -6
- metadata +46 -88
- data/bench.rb +0 -37
- data/mab-0.0.1.gem +0 -0
- data/markaby/CHANGELOG.rdoc +0 -106
- data/markaby/Markaby.gemspec +0 -109
- data/markaby/README.rdoc +0 -317
- data/markaby/Rakefile +0 -78
- data/markaby/VERSION +0 -1
- data/markaby/garlic.rb +0 -29
- data/markaby/init.rb +0 -6
- data/markaby/lib/markaby.rb +0 -30
- data/markaby/lib/markaby/builder.rb +0 -314
- data/markaby/lib/markaby/builder_tags.rb +0 -64
- data/markaby/lib/markaby/cssproxy.rb +0 -55
- data/markaby/lib/markaby/kernel_method.rb +0 -7
- data/markaby/lib/markaby/rails.rb +0 -75
- data/markaby/lib/markaby/rails/current.rb +0 -85
- data/markaby/lib/markaby/rails/deprecated.rb +0 -124
- data/markaby/lib/markaby/rails/rails_builder.rb +0 -91
- data/markaby/lib/markaby/sinatra.rb +0 -18
- data/markaby/lib/markaby/tags.rb +0 -200
- data/markaby/lib/markaby/tilt.rb +0 -8
- data/markaby/spec/markaby/builder_spec.rb +0 -118
- data/markaby/spec/markaby/css_proxy_test.rb +0 -47
- data/markaby/spec/markaby/fragment_test.rb +0 -10
- data/markaby/spec/markaby/markaby_other_static.mab +0 -1
- data/markaby/spec/markaby/markaby_spec.rb +0 -184
- data/markaby/spec/markaby/markaby_test.rb +0 -251
- data/markaby/spec/markaby/rails/spec_helper.rb +0 -29
- data/markaby/spec/markaby/rails/views/layouts/layout.mab +0 -11
- data/markaby/spec/markaby/rails/views/markaby/_a_partial.mab +0 -3
- data/markaby/spec/markaby/rails/views/markaby/_form_for_with_body_in_erb.erb +0 -1
- data/markaby/spec/markaby/rails/views/markaby/_partial_child_with_locals.mab +0 -1
- data/markaby/spec/markaby/rails/views/markaby/access_to_helpers.mab +0 -1
- data/markaby/spec/markaby/rails/views/markaby/broken.mab +0 -7
- data/markaby/spec/markaby/rails/views/markaby/commented_out_template.mab +0 -1
- data/markaby/spec/markaby/rails/views/markaby/correct_template_values.mab +0 -5
- data/markaby/spec/markaby/rails/views/markaby/double_output.mab +0 -8
- data/markaby/spec/markaby/rails/views/markaby/form_for.mab +0 -2
- data/markaby/spec/markaby/rails/views/markaby/form_for_with_fields.mab +0 -3
- data/markaby/spec/markaby/rails/views/markaby/form_for_with_multiple_fields.mab +0 -4
- data/markaby/spec/markaby/rails/views/markaby/no_values_passed.mab +0 -3
- data/markaby/spec/markaby/rails/views/markaby/partial_parent.mab +0 -1
- data/markaby/spec/markaby/rails/views/markaby/partial_parent_with_locals.mab +0 -7
- data/markaby/spec/markaby/rails/views/markaby/render_erb_without_explicit_render_call.erb +0 -1
- data/markaby/spec/markaby/rails/views/markaby/render_explicit_but_empty_markaby_layout.mab +0 -0
- data/markaby/spec/markaby/rails/views/markaby/render_mab_without_explicit_render_call.mab +0 -3
- data/markaby/spec/markaby/rails/views/markaby/render_with_ivar.mab +0 -3
- data/markaby/spec/markaby/rails/views/markaby/renders_erb.rhtml +0 -1
- data/markaby/spec/markaby/rails/views/markaby/renders_form_for_with_erb_body.mab +0 -3
- data/markaby/spec/markaby/rails/views/markaby/routes.mab +0 -1
- data/markaby/spec/markaby/rails/views/markaby/yielding.mab +0 -3
- data/markaby/spec/markaby/rails/views/markaby/yielding_content_for_with_block_helper.mab +0 -5
- data/markaby/spec/markaby/rails/views/markaby/yielding_two.mab +0 -7
- data/markaby/spec/markaby/rails/views/markaby/yielding_with_content_for.mab +0 -3
- data/markaby/spec/markaby/rails_test.rb +0 -380
- data/markaby/spec/markaby/rails_version_spec.rb +0 -37
- data/markaby/spec/markaby/sinatra/app.rb +0 -49
- data/markaby/spec/markaby/sinatra/sinatra_spec.rb +0 -67
- data/markaby/spec/markaby/sinatra/views/helpers.mab +0 -1
- data/markaby/spec/markaby/sinatra/views/layout.mab +0 -7
- data/markaby/spec/markaby/sinatra/views/markaby_template.mab +0 -0
- data/markaby/spec/markaby/sinatra/views/scope_instance_variables.mab +0 -3
- data/markaby/spec/markaby/sinatra/views/simple_html.mab +0 -4
- data/markaby/spec/markaby/sinatra/views/variables.mab +0 -3
- data/markaby/spec/markaby/tilt/erb.erb +0 -1
- data/markaby/spec/markaby/tilt/locals.mab +0 -1
- data/markaby/spec/markaby/tilt/markaby.mab +0 -1
- data/markaby/spec/markaby/tilt/markaby_other_static.mab +0 -1
- data/markaby/spec/markaby/tilt/render_twice.mab +0 -1
- data/markaby/spec/markaby/tilt/scope.mab +0 -1
- data/markaby/spec/markaby/tilt/yielding.mab +0 -2
- data/markaby/spec/markaby/tilt_spec.rb +0 -75
- data/markaby/spec/spec.opts +0 -2
- data/markaby/spec/spec_helper.rb +0 -44
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjhiNWMwM2NmNmQzMmI4OGU3Njg1YzBhN2FmZGIyNTc4NzU1ZmI4OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
M2U0YjA5MDE5NmZiYThhY2RlNTkzMGFiNDg0ZmQyMmRkMmIzNjRlZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YmIyZmJjNzNhMTQxZjNiZmQ0MDdmY2Y3MTNkZTJmYzYzMTAwNTFhOTQ2MGQw
|
10
|
+
Y2JkZGFiNTkyNmMwZWUwOGZkMzViZGFlZGE1NzFjMjVhZDEwOGJmOGEyMDU2
|
11
|
+
OGQxZmI0ZWRjODNkODliNjJkOWI4ZGM4MWZjNzNhZTRmYjY2NTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTMyM2ZiOTM5NmQzOGMwNWQ5NTM0MDA0NzQwY2E3OTBmMjhlNzVhOGQzZjli
|
14
|
+
OGNkOTdkNGVkNWRkYTA3NzhkZTQyOTk3NmVkYTdhMWZkZGIxYmFkNmY3NTI2
|
15
|
+
MWVkM2UzMzg5ODg1ODJiMGQwMTgxZTY5MTgxOTdhNTcxZTIwNjU=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
|
3
3
|
task :default => :test
|
4
|
+
task :test => 'test:core'
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
namespace 'test' do
|
7
|
+
Rake::TestTask.new('core') do |t|
|
8
|
+
t.libs << 'lib' << 'test'
|
9
|
+
end
|
10
|
+
|
11
|
+
Rake::TestTask.new('rails') do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.test_files = FileList['test/rails/test/test_*.rb']
|
14
|
+
end
|
7
15
|
end
|
8
16
|
|
data/lib/mab.rb
CHANGED
data/lib/mab/indentation.rb
CHANGED
data/lib/mab/mixin.rb
CHANGED
@@ -4,33 +4,33 @@ module Mab
|
|
4
4
|
module Mixin
|
5
5
|
class Error < StandardError; end
|
6
6
|
class Tag
|
7
|
-
attr_accessor :
|
8
|
-
attr_reader :
|
7
|
+
attr_accessor :_name, :_content, :_attributes, :_block, :_has_content
|
8
|
+
attr_reader :_options, :_context, :_instance
|
9
9
|
|
10
10
|
def initialize(name, options, context, instance = nil)
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
11
|
+
@_name = name
|
12
|
+
@_options = options
|
13
|
+
@_context = context
|
14
|
+
@_instance = instance
|
15
|
+
@_done = false
|
16
16
|
|
17
|
-
@
|
18
|
-
@
|
17
|
+
@_content = nil
|
18
|
+
@_has_content = nil
|
19
19
|
|
20
|
-
@
|
20
|
+
@_attributes = {}
|
21
21
|
|
22
|
-
@
|
22
|
+
@_pos = @_context.size
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
return @
|
27
|
-
current = @
|
28
|
-
@
|
25
|
+
def _block
|
26
|
+
return @_block unless block_given?
|
27
|
+
current = @_block
|
28
|
+
@_block = proc { yield current }
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def _merge_attributes(*args)
|
32
32
|
args.each do |attrs|
|
33
|
-
@
|
33
|
+
@_attributes.merge!(attrs)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -38,60 +38,60 @@ module Mab
|
|
38
38
|
name = name.to_s
|
39
39
|
|
40
40
|
if name[-1] == ?!
|
41
|
-
@
|
41
|
+
@_attributes[:id] = name[0..-2]
|
42
42
|
else
|
43
|
-
if @
|
44
|
-
@
|
43
|
+
if @_attributes.has_key?(:class)
|
44
|
+
@_attributes[:class] += " #{name}"
|
45
45
|
else
|
46
|
-
@
|
46
|
+
@_attributes[:class] = name
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
_insert(*args, &blk)
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
raise Error, "This tag is already closed" if @
|
53
|
+
def _insert(*args, &blk)
|
54
|
+
raise Error, "This tag is already closed" if @_done
|
55
55
|
|
56
56
|
if !args.empty? && !args[0].is_a?(Hash)
|
57
57
|
content = args.shift
|
58
|
-
raise Error, "Tag doesn't allow content" if @
|
59
|
-
@
|
58
|
+
raise Error, "Tag doesn't allow content" if @_has_content == false
|
59
|
+
@_has_content = true
|
60
60
|
end
|
61
61
|
|
62
62
|
if content
|
63
|
-
@
|
64
|
-
@
|
63
|
+
@_content = CGI.escapeHTML(content.to_s)
|
64
|
+
@_done = true
|
65
65
|
end
|
66
66
|
|
67
67
|
if !args.empty?
|
68
|
-
|
69
|
-
@
|
68
|
+
_merge_attributes(*args)
|
69
|
+
@_done = true
|
70
70
|
end
|
71
71
|
|
72
72
|
if block_given?
|
73
|
-
raise Error, "Tag doesn't allow content" if @
|
74
|
-
@
|
75
|
-
@
|
76
|
-
@
|
73
|
+
raise Error, "Tag doesn't allow content" if @_has_content == false
|
74
|
+
@_has_content = true
|
75
|
+
@_block = blk
|
76
|
+
@_done = true
|
77
77
|
end
|
78
78
|
|
79
|
-
if @
|
80
|
-
raise Error, "Both content and
|
79
|
+
if @_content && @_block
|
80
|
+
raise Error, "Both content and _block is not allowed"
|
81
81
|
end
|
82
82
|
|
83
|
-
@
|
83
|
+
@_instance.mab_done(self) if @_done
|
84
84
|
|
85
|
-
if @
|
86
|
-
before = @
|
87
|
-
res = @
|
85
|
+
if @_block
|
86
|
+
before = @_context.children
|
87
|
+
res = @_block.call
|
88
88
|
|
89
|
-
if before >= @
|
90
|
-
@
|
89
|
+
if before >= @_context.children
|
90
|
+
@_content = res.to_s
|
91
91
|
else
|
92
92
|
# Turn the node into just an opening tag.
|
93
|
-
@
|
94
|
-
@
|
93
|
+
@_has_content = false
|
94
|
+
@_instance.mab_insert("</#{@_name}>")
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -101,8 +101,8 @@ module Mab
|
|
101
101
|
def to_ary() nil end
|
102
102
|
def to_str() to_s end
|
103
103
|
|
104
|
-
def
|
105
|
-
|
104
|
+
def _attrs_to_s
|
105
|
+
@_attributes.inject("") do |res, (name, value)|
|
106
106
|
if value
|
107
107
|
value = (value == true) ? name : CGI.escapeHTML(value.to_s)
|
108
108
|
res << " #{name}=\"#{value}\""
|
@@ -112,14 +112,14 @@ module Mab
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def to_s
|
115
|
-
if !@
|
116
|
-
@
|
117
|
-
@
|
115
|
+
if !@_context.joining? && @_context[@_pos]
|
116
|
+
@_context[@_pos] = nil
|
117
|
+
@_context.children -= 1
|
118
118
|
end
|
119
119
|
|
120
|
-
res = "<#{@
|
121
|
-
res << (@
|
122
|
-
res << "#{@
|
120
|
+
res = "<#{@_name}#{_attrs_to_s}"
|
121
|
+
res << (@_options[:xml] && !@_block && !@_has_content ? ' />' : '>')
|
122
|
+
res << "#{@_content}</#{@_name}>" if @_has_content
|
123
123
|
res
|
124
124
|
end
|
125
125
|
end
|
@@ -156,7 +156,7 @@ module Mab
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def tag!(name, *args, &blk)
|
159
|
-
mab_tag(name).
|
159
|
+
mab_tag(name)._insert(*args, &blk)
|
160
160
|
end
|
161
161
|
|
162
162
|
def text!(str)
|
@@ -201,8 +201,8 @@ module Mab
|
|
201
201
|
class_eval <<-EOF
|
202
202
|
def #{meth}(*args, &blk)
|
203
203
|
tag = mab_tag(:#{tag})
|
204
|
-
tag.
|
205
|
-
tag.
|
204
|
+
tag._has_content = true
|
205
|
+
tag._insert(*args, &blk)
|
206
206
|
end
|
207
207
|
EOF
|
208
208
|
end
|
@@ -217,8 +217,8 @@ module Mab
|
|
217
217
|
class_eval <<-EOF
|
218
218
|
def #{meth}(*args, &blk)
|
219
219
|
tag = mab_tag(:#{tag})
|
220
|
-
tag.
|
221
|
-
tag.
|
220
|
+
tag._has_content = false
|
221
|
+
tag._insert(*args, &blk)
|
222
222
|
end
|
223
223
|
EOF
|
224
224
|
end
|
data/lib/mab/rails.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Mab
|
2
|
+
class RailsBuilder < Builder
|
3
|
+
def content_for(*args)
|
4
|
+
blk = proc do |*a|
|
5
|
+
mab { yield(*a) }.html_safe
|
6
|
+
end if block_given?
|
7
|
+
|
8
|
+
@_helper.send(:content_for, *args, &blk)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class RailsHandler
|
13
|
+
def call(template)
|
14
|
+
"::Mab::RailsBuilder.new({}, self) { #{template.source} }.to_s"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
::ActionView::Template.register_template_handler :mab, RailsHandler.new
|
19
|
+
end
|
20
|
+
|
data/lib/mab/version.rb
CHANGED
data/test/rails/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "rails/test_unit/railtie"
|
5
|
+
|
6
|
+
require "mab"
|
7
|
+
|
8
|
+
if defined?(Bundler)
|
9
|
+
# If you precompile assets before deploying to production, use this line
|
10
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
11
|
+
# If you want your assets lazily compiled in production, use this line
|
12
|
+
# Bundler.require(:default, :assets, Rails.env)
|
13
|
+
end
|
14
|
+
|
15
|
+
module Dummy
|
16
|
+
class Application < Rails::Application
|
17
|
+
# Settings in config/environments/* take precedence over those specified here.
|
18
|
+
# Application configuration should go into files in config/initializers
|
19
|
+
# -- all .rb files in that directory are automatically loaded.
|
20
|
+
|
21
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
22
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
23
|
+
|
24
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
25
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
26
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
27
|
+
|
28
|
+
# Activate observers that should always be running.
|
29
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
30
|
+
|
31
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
32
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
33
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
34
|
+
|
35
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
36
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
37
|
+
# config.i18n.default_locale = :de
|
38
|
+
|
39
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
40
|
+
config.encoding = "utf-8"
|
41
|
+
|
42
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
43
|
+
config.filter_parameters += [:password]
|
44
|
+
|
45
|
+
# Enable escaping HTML in JSON.
|
46
|
+
config.active_support.escape_html_entities_in_json = true
|
47
|
+
|
48
|
+
# Enable the asset pipeline
|
49
|
+
config.assets.enabled = true
|
50
|
+
|
51
|
+
# Version of your assets, change this if you want to expire all your assets
|
52
|
+
config.assets.version = '1.0'
|
53
|
+
end
|
54
|
+
end
|