masterview 0.1.3 → 0.1.5
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.
- data/CHANGELOG +4 -0
- data/README +18 -2
- data/RELEASE_NOTES +1 -1
- data/init.rb +1 -0
- data/lib/masterview/directive_helpers.rb +2 -0
- data/lib/masterview/directives/insert_generated_comment.rb +3 -3
- data/lib/masterview/directives/omit_tag.rb +32 -0
- data/lib/masterview/masterview_version.rb +1 -1
- data/lib/masterview.rb +8 -0
- data/test/omit_tag_test.rb +40 -0
- data/test/template_test.rb +80 -0
- metadata +24 -22
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
0.1.5 - May 31st - Remove app_[ENV] customization hook in leau of a block based initializer approach (similar to rails) from Deborah Lewis which would allow customization from the environment config files.
|
2
|
+
|
3
|
+
0.1.4 - May 30th - Apply patch by Deborah Lewis to allow customized generated comment. Add omit_tag directive to conditionally suppress output of element tag. Add user configuration user.rb, user_RAILS_ENV.rb
|
4
|
+
|
1
5
|
0.1.3 - May 29th - Fixed generators to use m.file not m.template on non-erb files
|
2
6
|
|
3
7
|
0.1.2 - May 29th - Fix empty.rhtml not being found from rake mv:copy_layout
|
data/README
CHANGED
@@ -45,7 +45,7 @@ If you can use gems you may simply do the following
|
|
45
45
|
|
46
46
|
gem install masterview_gem_pack
|
47
47
|
|
48
|
-
Now your gem is installed and you can skip these steps in the future. After creating your rails directory, change directory to it and run the following to create a very lightweight plugin instance for this application mainly consisting of an init.rb file which will get loaded at runtime. This init.rb refers to the gem for everything but allows you to override any constants or setup that has been provided. See MasterView module masterview.rb for a list of the available constants.
|
48
|
+
Now your gem is installed and you can skip these steps in the future. After creating your rails directory, change directory to it and run the following to create a very lightweight plugin instance for this application mainly consisting of an init.rb file which will get loaded at runtime. This init.rb refers to the gem for everything but allows you to override any constants or setup that has been provided. See MasterView module masterview.rb for a list of the available constants.
|
49
49
|
|
50
50
|
script/generate masterview_plugin
|
51
51
|
|
@@ -53,7 +53,7 @@ After this MasterView is ready for use. Skip down to the Usage section for more
|
|
53
53
|
|
54
54
|
=== Installation without using gems, install as plugin
|
55
55
|
|
56
|
-
script/plugin install svn://rubyforge.org/var/svn/masterview
|
56
|
+
script/plugin install svn://rubyforge.org/var/svn/masterview/tags/latest
|
57
57
|
|
58
58
|
This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. Note that if you don't have svn (subversion) installed, you may also retrieve the plugin package (masterview_plugin.tgz or masterview_plugin.zip) from http://rubyforge.org/projects/masterview and simply extract into vendor/plugins/masterview
|
59
59
|
|
@@ -386,6 +386,22 @@ mv:link_to_remote="linkToRemoteOptions"
|
|
386
386
|
|
387
387
|
<%= link_to_remote 'New product', :action => 'new' %>
|
388
388
|
|
389
|
+
mv:omit_tag="evalString"
|
390
|
+
Omit the element tag if the evalString is empty or evaluates to true. For example...
|
391
|
+
|
392
|
+
<span mv:omit_tag="">hello</span>
|
393
|
+
|
394
|
+
becomes
|
395
|
+
|
396
|
+
hello
|
397
|
+
|
398
|
+
<span mv:omit_tag="@test">hello</span>
|
399
|
+
|
400
|
+
becomes
|
401
|
+
|
402
|
+
<% if @test %><span><% end %>hello<% if @test %></span><% end %>
|
403
|
+
|
404
|
+
|
389
405
|
mv:password_field="user, password"
|
390
406
|
Replaces the tag with a password_field helper using the attribute as well as merging any html
|
391
407
|
attributes that have been set by the designer, for example...
|
data/RELEASE_NOTES
CHANGED
@@ -66,7 +66,7 @@ After this MasterView is ready for use. Skip down to the Usage section for more
|
|
66
66
|
|
67
67
|
=== Installation without using gems, install as plugin
|
68
68
|
|
69
|
-
script/plugin install svn://rubyforge.org/var/svn/masterview
|
69
|
+
script/plugin install svn://rubyforge.org/var/svn/masterview/tags/latest
|
70
70
|
|
71
71
|
This will copy entire MasterView system into your vendor/plugin/masterview directory. You may tweak its init.rb to override any MasterView constants at runtime. See MasterView module masterview.rb for a list of available constants. Note that if you don't have svn (subversion) installed, you may also retrieve the plugin package (masterview_plugin.tgz or masterview_plugin.zip) from http://rubyforge.org/projects/masterview and simply extract into vendor/plugins/masterview
|
72
72
|
|
data/init.rb
CHANGED
@@ -34,6 +34,7 @@ require 'masterview'
|
|
34
34
|
|
35
35
|
module ::MasterView
|
36
36
|
#override any constants here, see masterview.rb for more
|
37
|
+
#Note that you may also put your override configuration in vendor/plugins/masterview/user.rb and user_development.rb, user_test.rb, ...
|
37
38
|
#DefaultDirectiveLoadPaths.push File.join( File.dirname(__FILE__), 'directives') #uncomment if you want to add a local directives dir
|
38
39
|
#DefaultParserOptions = { :tidy => false, :escape_erb => true }
|
39
40
|
#TidyPath = '/usr/lib/libtidy.so'
|
@@ -10,6 +10,7 @@ module MasterView
|
|
10
10
|
#higher priority (lower value) will be executed first in chain
|
11
11
|
module DirectivePriorities
|
12
12
|
Highest = 0
|
13
|
+
UltraHigh = 0x3FFFFFFF/16
|
13
14
|
VeryHigh = 0x3FFFFFFF/8
|
14
15
|
High = 0x3FFFFFFF/4
|
15
16
|
MediumHigh = 0x3FFFFFFF/3
|
@@ -17,6 +18,7 @@ module MasterView
|
|
17
18
|
MediumLow = (0x3FFFFFFF/3)*2
|
18
19
|
Low = (0x3FFFFFFF/4)*3
|
19
20
|
VeryLow = (0x3FFFFFFF/8)*7
|
21
|
+
UltraLow = (0x3FFFFFFF/16)*15
|
20
22
|
Lowest = 0x3FFFFFFF
|
21
23
|
end
|
22
24
|
|
@@ -5,7 +5,7 @@ module MasterView
|
|
5
5
|
# and should not be edited, else changes could be lost. It includes the path to
|
6
6
|
# the original file that should be edited instead
|
7
7
|
class Insert_generated_comment < MasterView::DirectiveBase
|
8
|
-
Generated_comment_text = <<-END
|
8
|
+
Generated_comment_text = MasterView::GeneratedCommentTemplate || <<-END
|
9
9
|
# WARNING - This file was generated by MasterView plugin.
|
10
10
|
# Do not edit this file otherwise you may lose your changes
|
11
11
|
# when this file is re-generated.
|
@@ -14,11 +14,11 @@ module MasterView
|
|
14
14
|
END
|
15
15
|
|
16
16
|
def priority
|
17
|
-
DirectivePriorities::
|
17
|
+
DirectivePriorities::VeryLow
|
18
18
|
end
|
19
19
|
|
20
20
|
def stag(directive_call_stack)
|
21
|
-
comment = "\n<% \n" + Generated_comment_text + "# "+ attr_value + "\n
|
21
|
+
comment = "\n<% \n" + Generated_comment_text + "# "+ attr_value + "\n-%>"
|
22
22
|
|
23
23
|
ret = []
|
24
24
|
ret << directive_call_stack.render
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MasterView
|
2
|
+
module Directives
|
3
|
+
|
4
|
+
# omit tag if attr_value is empty or if at runtime the condition evaluates to true
|
5
|
+
# mv:omit_tag="" will not render the tag,
|
6
|
+
# mv:omit_tag="true" will not render the tag,
|
7
|
+
# mv:omit_tag="false" will render the tag
|
8
|
+
class Omit_tag < MasterView::DirectiveBase
|
9
|
+
def priority
|
10
|
+
DirectivePriorities::UltraLow
|
11
|
+
end
|
12
|
+
|
13
|
+
def stag(dcs)
|
14
|
+
ret = []
|
15
|
+
unless attr_value.empty?
|
16
|
+
ret << erb('if '+attr_value)
|
17
|
+
ret << dcs.render
|
18
|
+
ret << erb('end')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def etag(dcs)
|
23
|
+
ret = []
|
24
|
+
unless attr_value.empty?
|
25
|
+
ret << erb('if '+attr_value)
|
26
|
+
ret << dcs.render
|
27
|
+
ret << erb('end')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/masterview.rb
CHANGED
@@ -61,6 +61,14 @@ module MasterView
|
|
61
61
|
# the generated file should not be manually edited, false = generate the warning comments
|
62
62
|
OmitGeneratedComments = false
|
63
63
|
|
64
|
+
# template for comment inserted in generated files from MasterView master
|
65
|
+
GeneratedCommentTemplate = <<-END
|
66
|
+
# WARNING - This is a generated file created by MasterView.
|
67
|
+
# Do not edit - changes will be lost when this file is re-generated.
|
68
|
+
#
|
69
|
+
# To make changes, edit the MasterView source file located at:
|
70
|
+
END
|
71
|
+
|
64
72
|
# relative path from RAILS_ROOT to where backup files should be created before rebuilding/updating a template file, use nil to suppress backups
|
65
73
|
DirectoryForRebuildBackups = 'tmp/masterview/rebuild/backups'
|
66
74
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
currentPath = File.dirname(__FILE__)
|
5
|
+
require File.join( currentPath, '../lib/masterview' )
|
6
|
+
require File.join( currentPath, '../lib/masterview/directives/omit_tag')
|
7
|
+
|
8
|
+
class TestOmit_tag < Test::Unit::TestCase
|
9
|
+
include MasterView::Directives
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@directives = MasterView::DirectiveSet.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_omit_tag
|
16
|
+
tag = MasterView::Tag.new(@directives, 'foo', { 'id' => 'foobar', 'style' => 'test'}, :normal, nil)
|
17
|
+
@directives.directives = []
|
18
|
+
attr_value = ""
|
19
|
+
@directives << Omit_tag.new(attr_value)
|
20
|
+
assert_equal nil, @directives.determine_dcs(:stag).render
|
21
|
+
dcs = @directives.determine_dcs(:etag)
|
22
|
+
dcs.context = tag.create_context
|
23
|
+
dcs.context[:tag].content = "hello world"
|
24
|
+
assert_equal nil, dcs.render
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_omit_tag_eval
|
28
|
+
tag = MasterView::Tag.new(@directives, 'foo', { 'id' => 'foobar', 'style' => 'test'}, :normal, nil)
|
29
|
+
@directives.directives = []
|
30
|
+
attr_value = "@test"
|
31
|
+
@directives << Omit_tag.new(attr_value)
|
32
|
+
assert_equal ["<% if @test %>", [], "<% end %>"], @directives.determine_dcs(:stag).render
|
33
|
+
dcs = @directives.determine_dcs(:etag)
|
34
|
+
dcs.context = tag.create_context
|
35
|
+
dcs.context[:tag].content = "hello world"
|
36
|
+
assert_equal ["<% if @test %>", [], "<% end %>"], dcs.render
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
data/test/template_test.rb
CHANGED
@@ -291,4 +291,84 @@ class TestTemplate < Test::Unit::TestCase
|
|
291
291
|
assert_template_result expected, template
|
292
292
|
end
|
293
293
|
|
294
|
+
def test_omit_tag
|
295
|
+
template = <<-END
|
296
|
+
<div mv:generate='foo/bar'>
|
297
|
+
<div mv:omit_tag="">
|
298
|
+
<foo>bar</foo>
|
299
|
+
</div>
|
300
|
+
</div>
|
301
|
+
END
|
302
|
+
expected = {
|
303
|
+
'foo/bar' => "<div><foo>bar</foo></div>"
|
304
|
+
}
|
305
|
+
assert_template_result expected, template
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_omit_tag_eval
|
309
|
+
template = <<-END
|
310
|
+
<div mv:generate='foo/bar'>
|
311
|
+
<div mv:omit_tag="@hello">
|
312
|
+
<foo>bar</foo>
|
313
|
+
</div>
|
314
|
+
</div>
|
315
|
+
END
|
316
|
+
expected = {
|
317
|
+
'foo/bar' => "<div><% if @hello %><div><% end %><foo>bar</foo><% if @hello %></div><% end %></div>"
|
318
|
+
}
|
319
|
+
assert_template_result expected, template
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_omit_tag_root
|
323
|
+
template = <<-END
|
324
|
+
<div mv:generate='foo/bar' mv:omit_tag="">
|
325
|
+
hello world
|
326
|
+
</div>
|
327
|
+
END
|
328
|
+
expected = {
|
329
|
+
'foo/bar' => " hello world "
|
330
|
+
}
|
331
|
+
assert_template_result expected, template
|
332
|
+
end
|
333
|
+
|
334
|
+
def test_omit_tag_root_with_children
|
335
|
+
template = <<-END
|
336
|
+
<div mv:generate='foo/bar' mv:omit_tag="">
|
337
|
+
<foo>hello world</foo>
|
338
|
+
</div>
|
339
|
+
END
|
340
|
+
expected = {
|
341
|
+
'foo/bar' => " <foo>hello world</foo>"
|
342
|
+
}
|
343
|
+
assert_template_result expected, template
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_omit_tag_root_with_nested_generate
|
347
|
+
template = <<-END
|
348
|
+
<div mv:generate='foo/bar' mv:omit_tag="">
|
349
|
+
first layer
|
350
|
+
<foo mv:generate='baz/cat' mv:omit_tag="">hello world</foo>
|
351
|
+
</div>
|
352
|
+
END
|
353
|
+
expected = {
|
354
|
+
'foo/bar' => " first layer ",
|
355
|
+
'baz/cat' => "hello world"
|
356
|
+
}
|
357
|
+
assert_template_result expected, template
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_omit_tag_root_with_nested_gen_render
|
361
|
+
template = <<-END
|
362
|
+
<div mv:generate='foo/bar' mv:omit_tag="">
|
363
|
+
first layer
|
364
|
+
<foo mv:gen_render=":partial => 'baz/cat'" mv:omit_tag="">hello world</foo>
|
365
|
+
</div>
|
366
|
+
END
|
367
|
+
expected = {
|
368
|
+
'foo/bar' => " first layer <%= render( :partial => 'baz/cat' ) %>",
|
369
|
+
'baz/_cat.rhtml' => "hello world"
|
370
|
+
}
|
371
|
+
assert_template_result expected, template
|
372
|
+
end
|
373
|
+
|
294
374
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: masterview
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-05-
|
6
|
+
version: 0.1.5
|
7
|
+
date: 2006-05-31 00:00:00 -05:00
|
8
8
|
summary: A (x)html friendly template engine for rails with the power of layouts, and partials.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -44,13 +44,13 @@ files:
|
|
44
44
|
- lib/masterview/extras
|
45
45
|
- lib/masterview/plugin_load_tracking.rb
|
46
46
|
- lib/masterview/directive_helpers.rb
|
47
|
+
- lib/masterview/analyzer.rb
|
47
48
|
- lib/masterview/runtime_helpers.rb
|
48
49
|
- lib/masterview/string_extensions.rb
|
50
|
+
- lib/masterview/template_spec.rb
|
49
51
|
- lib/masterview/directive_base.rb
|
50
52
|
- lib/masterview/masterview_version.rb
|
51
53
|
- lib/masterview/parser.rb
|
52
|
-
- lib/masterview/template_spec.rb
|
53
|
-
- lib/masterview/analyzer.rb
|
54
54
|
- lib/masterview/directives/global_inline_erb.rb
|
55
55
|
- lib/masterview/directives/link_to_if.rb
|
56
56
|
- lib/masterview/directives/preview.rb
|
@@ -64,17 +64,18 @@ files:
|
|
64
64
|
- lib/masterview/directives/link_to.rb
|
65
65
|
- lib/masterview/directives/elsif.rb
|
66
66
|
- lib/masterview/directives/form.rb
|
67
|
+
- lib/masterview/directives/omit_tag.rb
|
67
68
|
- lib/masterview/directives/submit.rb
|
68
|
-
- lib/masterview/directives/
|
69
|
+
- lib/masterview/directives/replace.rb
|
70
|
+
- lib/masterview/directives/attr.rb
|
69
71
|
- lib/masterview/directives/insert_generated_comment.rb
|
70
72
|
- lib/masterview/directives/stylesheet_link.rb
|
71
73
|
- lib/masterview/directives/javascript_include.rb
|
74
|
+
- lib/masterview/directives/import_render.rb
|
72
75
|
- lib/masterview/directives/link_to_remote.rb
|
76
|
+
- lib/masterview/directives/import.rb
|
73
77
|
- lib/masterview/directives/content.rb
|
74
|
-
- lib/masterview/directives/replace.rb
|
75
78
|
- lib/masterview/directives/text_area.rb
|
76
|
-
- lib/masterview/directives/attr.rb
|
77
|
-
- lib/masterview/directives/import_render.rb
|
78
79
|
- lib/masterview/extras/app
|
79
80
|
- lib/masterview/extras/rails_init.rb
|
80
81
|
- lib/masterview/extras/watcher.rb
|
@@ -83,43 +84,44 @@ files:
|
|
83
84
|
- lib/masterview/extras/app/controllers/masterview_controller.rb
|
84
85
|
- lib/masterview/extras/app/views/masterview
|
85
86
|
- lib/masterview/extras/app/views/masterview/admin
|
86
|
-
- lib/masterview/extras/app/views/masterview/admin/create.rhtml
|
87
|
-
- lib/masterview/extras/app/views/masterview/admin/empty.rhtml
|
88
87
|
- lib/masterview/extras/app/views/masterview/admin/list.rhtml
|
88
|
+
- lib/masterview/extras/app/views/masterview/admin/empty.rhtml
|
89
|
+
- lib/masterview/extras/app/views/masterview/admin/create.rhtml
|
89
90
|
- test/run_parser_test.rb
|
90
91
|
- test/test_helper.rb
|
91
|
-
- test/template_file_watcher_test.rb
|
92
92
|
- test/global_inline_erb_test.rb
|
93
|
-
- test/
|
94
|
-
- test/text_field_test.rb
|
95
|
-
- test/else_test.rb
|
93
|
+
- test/template_spec_test.rb
|
96
94
|
- test/block_test.rb
|
95
|
+
- test/else_test.rb
|
96
|
+
- test/template_file_watcher_test.rb
|
97
|
+
- test/text_field_test.rb
|
98
|
+
- test/hidden_field_test.rb
|
97
99
|
- test/example_test.rb
|
98
100
|
- test/parser_test.rb
|
99
101
|
- test/if_test.rb
|
100
|
-
- test/
|
102
|
+
- test/text_area_test.rb
|
101
103
|
- test/link_to_test.rb
|
102
104
|
- test/elsif_test.rb
|
103
105
|
- test/form_test.rb
|
106
|
+
- test/omit_tag_test.rb
|
104
107
|
- test/submit_test.rb
|
105
108
|
- test/javascript_include_test.rb
|
109
|
+
- test/password_field_test.rb
|
106
110
|
- test/stylesheet_link_test.rb
|
107
111
|
- test/filter_helpers_test.rb
|
108
|
-
- test/
|
112
|
+
- test/import_test.rb
|
113
|
+
- test/import_render_test.rb
|
109
114
|
- test/content_test.rb
|
115
|
+
- test/attr_test.rb
|
110
116
|
- test/replace_test.rb
|
111
117
|
- test/template_test.rb
|
112
|
-
- test/template_spec_test.rb
|
113
118
|
- test/link_to_if_test.rb
|
114
|
-
- test/import_test.rb
|
115
|
-
- test/attr_test.rb
|
116
|
-
- test/import_render_test.rb
|
117
119
|
- CHANGELOG
|
120
|
+
- MIT-LICENSE
|
118
121
|
- Rakefile
|
122
|
+
- TODO
|
119
123
|
- RELEASE_NOTES
|
120
|
-
- MIT-LICENSE
|
121
124
|
- README
|
122
|
-
- TODO
|
123
125
|
- init.rb
|
124
126
|
test_files: []
|
125
127
|
|