masterview 0.2.2 → 0.2.3
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 +14 -0
- data/RELEASE_NOTES +12 -0
- data/TODO +16 -1
- data/doc/configuration.html +19 -8
- data/doc/directives.html +173 -4
- data/doc/guide.html +2 -2
- data/doc/index.html +2 -2
- data/doc/stylesheets/masterview.css +13 -0
- data/examples/rails_app_config/masterview/environment/development.rb +2 -2
- data/lib/masterview/attr_string_parser.rb +105 -0
- data/lib/masterview/directive_base.rb +146 -14
- data/lib/masterview/directive_helpers.rb +22 -8
- data/lib/masterview/directive_registry.rb +169 -0
- data/lib/masterview/directives/check_box.rb +31 -0
- data/lib/masterview/directives/collection_select.rb +44 -0
- data/lib/masterview/directives/hidden_field.rb +2 -2
- data/lib/masterview/directives/image_tag.rb +4 -1
- data/lib/masterview/directives/insert_generated_comment.rb +7 -6
- data/lib/masterview/directives/javascript_include.rb +4 -1
- data/lib/masterview/directives/password_field.rb +2 -2
- data/lib/masterview/directives/radio_button.rb +35 -0
- data/lib/masterview/directives/select.rb +38 -0
- data/lib/masterview/directives/stylesheet_link.rb +4 -1
- data/lib/masterview/directives/text_area.rb +2 -2
- data/lib/masterview/directives/text_field.rb +2 -2
- data/lib/masterview/extras/app/controllers/masterview_controller.rb +46 -59
- data/lib/masterview/extras/app/views/layouts/masterview_admin.rhtml +73 -0
- data/lib/masterview/extras/app/views/masterview/admin/configuration.rhtml +1 -0
- data/lib/masterview/extras/app/views/masterview/admin/list.rhtml +1 -1
- data/lib/masterview/initializer.rb +73 -20
- data/lib/masterview/masterview_info.rb +117 -0
- data/lib/masterview/masterview_version.rb +1 -1
- data/lib/masterview/parser.rb +22 -35
- data/lib/masterview/plugin_load_tracking.rb +17 -8
- data/lib/masterview.rb +3 -0
- data/test/fixtures/configs/fake_rails_app_with_config/config/masterview/environments/production.rb +5 -1
- data/test/unit/config_settings_test.rb +16 -4
- data/test/unit/directive_base_test.rb +29 -0
- data/test/unit/directive_helpers_parse_test.rb +324 -0
- data/test/unit/template_test.rb +242 -0
- metadata +14 -2
data/test/unit/template_test.rb
CHANGED
@@ -624,6 +624,248 @@ class TestTemplate < Test::Unit::TestCase
|
|
624
624
|
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
625
625
|
end
|
626
626
|
|
627
|
+
def test_check_box
|
628
|
+
template = <<-END
|
629
|
+
<div mv:generate='foo/bar'>
|
630
|
+
<input type="checkbox" mv:check_box="cat, dog, {:egg => 'chicken'}, 'yes', 'no'"/>
|
631
|
+
</div>
|
632
|
+
END
|
633
|
+
expected = {
|
634
|
+
'foo/bar' => "<div><%= check_box 'cat', 'dog', {:egg => 'chicken'}, 'yes', 'no' %></div>"
|
635
|
+
}
|
636
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
637
|
+
end
|
638
|
+
|
639
|
+
def test_check_box_object_method
|
640
|
+
template = <<-END
|
641
|
+
<div mv:generate='foo/bar'>
|
642
|
+
<input type="checkbox" mv:check_box="cat, dog"/>
|
643
|
+
</div>
|
644
|
+
END
|
645
|
+
expected = {
|
646
|
+
'foo/bar' => "<div><%= check_box 'cat', 'dog' %></div>"
|
647
|
+
}
|
648
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
649
|
+
end
|
650
|
+
|
651
|
+
def test_check_box_object_method_options
|
652
|
+
template = <<-END
|
653
|
+
<div mv:generate='foo/bar'>
|
654
|
+
<input type="checkbox" mv:check_box="cat, dog, :egg => 'chicken'"/>
|
655
|
+
</div>
|
656
|
+
END
|
657
|
+
expected = {
|
658
|
+
'foo/bar' => "<div><%= check_box 'cat', 'dog', :egg => 'chicken' %></div>"
|
659
|
+
}
|
660
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
661
|
+
end
|
662
|
+
|
663
|
+
def test_check_box_object_method_class_id
|
664
|
+
template = <<-END
|
665
|
+
<div mv:generate='foo/bar'>
|
666
|
+
<input type="checkbox" class="green" id="boo" mv:check_box="cat, dog"/>
|
667
|
+
</div>
|
668
|
+
END
|
669
|
+
expected = {
|
670
|
+
'foo/bar' => "<div><%= check_box 'cat', 'dog', :class => \"green\", :id => \"boo\" %></div>"
|
671
|
+
}
|
672
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
673
|
+
end
|
674
|
+
|
675
|
+
def test_check_box_object_method_options_class_id
|
676
|
+
template = <<-END
|
677
|
+
<div mv:generate='foo/bar'>
|
678
|
+
<input type="checkbox" class="green" id="boo" mv:check_box="cat, dog, :hello => 'world'"/>
|
679
|
+
</div>
|
680
|
+
END
|
681
|
+
expected = {
|
682
|
+
'foo/bar' => "<div><%= check_box 'cat', 'dog', :hello => 'world', :class => \"green\", :id => \"boo\" %></div>"
|
683
|
+
}
|
684
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
685
|
+
end
|
686
|
+
|
687
|
+
def test_radio_button
|
688
|
+
template = <<-END
|
689
|
+
<div mv:generate='foo/bar'>
|
690
|
+
<input type="radio" mv:radio_button="cat, dog, 'egg'"/>
|
691
|
+
</div>
|
692
|
+
END
|
693
|
+
expected = {
|
694
|
+
'foo/bar' => "<div><%= radio_button 'cat', 'dog', 'egg' %></div>"
|
695
|
+
}
|
696
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
697
|
+
end
|
698
|
+
|
699
|
+
def test_radio_button_quoted
|
700
|
+
template = <<-END
|
701
|
+
<div mv:generate='foo/bar'>
|
702
|
+
<input type="radio" mv:radio_button="'cat', 'dog', 'egg'"/>
|
703
|
+
</div>
|
704
|
+
END
|
705
|
+
expected = {
|
706
|
+
'foo/bar' => "<div><%= radio_button 'cat', 'dog', 'egg' %></div>"
|
707
|
+
}
|
708
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
709
|
+
end
|
710
|
+
|
711
|
+
def test_radio_button_object_method_class_id
|
712
|
+
template = <<-END
|
713
|
+
<div mv:generate='foo/bar'>
|
714
|
+
<input type="radio" class="green" id="boo" mv:radio_button="cat, dog, 'egg'"/>
|
715
|
+
</div>
|
716
|
+
END
|
717
|
+
expected = {
|
718
|
+
'foo/bar' => "<div><%= radio_button 'cat', 'dog', 'egg', :class => \"green\", :id => \"boo\" %></div>"
|
719
|
+
}
|
720
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
721
|
+
end
|
722
|
+
|
723
|
+
def test_radio_button_object_method_options_class_id
|
724
|
+
template = <<-END
|
725
|
+
<div mv:generate='foo/bar'>
|
726
|
+
<input type="radio" class="green" id="boo" mv:radio_button="cat, dog, 'egg', :hello => 'world'"/>
|
727
|
+
</div>
|
728
|
+
END
|
729
|
+
expected = {
|
730
|
+
'foo/bar' => "<div><%= radio_button 'cat', 'dog', 'egg', :hello => 'world', :class => \"green\", :id => \"boo\" %></div>"
|
731
|
+
}
|
732
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
733
|
+
end
|
734
|
+
|
735
|
+
def test_select
|
736
|
+
template = <<-END
|
737
|
+
<div mv:generate='foo/bar'>
|
738
|
+
<select mv:select="product, category_id, ['hardware', 'software'], {:hello => 'world'}, :readonly => true">
|
739
|
+
<option value="foo">Foo</option>
|
740
|
+
<option value="bar">Bar</option>
|
741
|
+
</select>
|
742
|
+
</div>
|
743
|
+
END
|
744
|
+
expected = {
|
745
|
+
'foo/bar' => "<div><%= select 'product', 'category_id', ['hardware', 'software'], {:hello => 'world'}, :readonly => true %></div>"
|
746
|
+
}
|
747
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
748
|
+
end
|
749
|
+
|
750
|
+
def test_select_obj_method_choices
|
751
|
+
template = <<-END
|
752
|
+
<div mv:generate='foo/bar'>
|
753
|
+
<select mv:select="product, category_id, ['hardware', 'software']">
|
754
|
+
<option value="foo">Foo</option>
|
755
|
+
<option value="bar">Bar</option>
|
756
|
+
</select>
|
757
|
+
</div>
|
758
|
+
END
|
759
|
+
expected = {
|
760
|
+
'foo/bar' => "<div><%= select 'product', 'category_id', ['hardware', 'software'] %></div>"
|
761
|
+
}
|
762
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
763
|
+
end
|
764
|
+
|
765
|
+
def test_select_obj_method_choices_find
|
766
|
+
template = <<-END
|
767
|
+
<div mv:generate='foo/bar'>
|
768
|
+
<select mv:select="product, category_id, Categories.find_all.collect{|c| [c.name, c.id]}">
|
769
|
+
<option value="foo">Foo</option>
|
770
|
+
<option value="bar">Bar</option>
|
771
|
+
</select>
|
772
|
+
</div>
|
773
|
+
END
|
774
|
+
expected = {
|
775
|
+
'foo/bar' => "<div><%= select 'product', 'category_id', Categories.find_all.collect{|c| [c.name, c.id]} %></div>"
|
776
|
+
}
|
777
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
778
|
+
end
|
779
|
+
|
780
|
+
def test_select_obj_method_choices_find_class_id
|
781
|
+
template = <<-END
|
782
|
+
<div mv:generate='foo/bar'>
|
783
|
+
<select class="green" id="sel1" mv:select="product, category_id, Categories.find_all.collect{|c| [c.name, c.id]}, {:hello => :world}, :readonly => true">
|
784
|
+
<option value="foo">Foo</option>
|
785
|
+
<option value="bar">Bar</option>
|
786
|
+
</select>
|
787
|
+
</div>
|
788
|
+
END
|
789
|
+
expected = {
|
790
|
+
'foo/bar' => "<div><%= select 'product', 'category_id', Categories.find_all.collect{|c| [c.name, c.id]}, {:hello => :world}, :readonly => true, :class => \"green\", :id => \"sel1\" %></div>"
|
791
|
+
}
|
792
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
793
|
+
end
|
794
|
+
|
795
|
+
def test_collection_select
|
796
|
+
template = <<-END
|
797
|
+
<div mv:generate='foo/bar'>
|
798
|
+
<select mv:collection_select="product, category_id, Category.find(:all), id, name, {:hello => 'world'}, :readonly => true">
|
799
|
+
<option value="foo">Foo</option>
|
800
|
+
<option value="bar">Bar</option>
|
801
|
+
</select>
|
802
|
+
</div>
|
803
|
+
END
|
804
|
+
expected = {
|
805
|
+
'foo/bar' => "<div><%= collection_select 'product', 'category_id', Category.find(:all), 'id', 'name', {:hello => 'world'}, :readonly => true %></div>"
|
806
|
+
}
|
807
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
808
|
+
end
|
809
|
+
|
810
|
+
def test_collection_select_short
|
811
|
+
template = <<-END
|
812
|
+
<div mv:generate='foo/bar'>
|
813
|
+
<select mv:collection_select="product, category_id, Category.find(:all), id, name">
|
814
|
+
<option value="foo">Foo</option>
|
815
|
+
<option value="bar">Bar</option>
|
816
|
+
</select>
|
817
|
+
</div>
|
818
|
+
END
|
819
|
+
expected = {
|
820
|
+
'foo/bar' => "<div><%= collection_select 'product', 'category_id', Category.find(:all), 'id', 'name' %></div>"
|
821
|
+
}
|
822
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
823
|
+
end
|
824
|
+
|
825
|
+
def test_collection_select_symbols
|
826
|
+
template = <<-END
|
827
|
+
<div mv:generate='foo/bar'>
|
828
|
+
<select mv:collection_select="product, category_id, Category.find(:all), :id, :name, {:hello => 'world'}, :readonly => true">
|
829
|
+
<option value="foo">Foo</option>
|
830
|
+
<option value="bar">Bar</option>
|
831
|
+
</select>
|
832
|
+
</div>
|
833
|
+
END
|
834
|
+
expected = {
|
835
|
+
'foo/bar' => "<div><%= collection_select 'product', 'category_id', Category.find(:all), :id, :name, {:hello => 'world'}, :readonly => true %></div>"
|
836
|
+
}
|
837
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
838
|
+
end
|
839
|
+
|
840
|
+
def test_collection_select_merging_html
|
841
|
+
template = <<-END
|
842
|
+
<div mv:generate='foo/bar'>
|
843
|
+
<select class="green" id="sel1" mv:collection_select="product, category_id, Category.find(:all), id, name, {:hello => 'world'}, :readonly => true">
|
844
|
+
<option value="foo">Foo</option>
|
845
|
+
<option value="bar">Bar</option>
|
846
|
+
</select>
|
847
|
+
</div>
|
848
|
+
END
|
849
|
+
expected = {
|
850
|
+
'foo/bar' => "<div><%= collection_select 'product', 'category_id', Category.find(:all), 'id', 'name', {:hello => 'world'}, :readonly => true, :class => \"green\", :id => \"sel1\" %></div>"
|
851
|
+
}
|
852
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
853
|
+
end
|
854
|
+
|
855
|
+
def test_collection_select_no_options_merging_html
|
856
|
+
template = <<-END
|
857
|
+
<div mv:generate='foo/bar'>
|
858
|
+
<select class="green" id="sel1" mv:collection_select="product, category_id, Category.find(:all), id, name">
|
859
|
+
<option value="foo">Foo</option>
|
860
|
+
<option value="bar">Bar</option>
|
861
|
+
</select>
|
862
|
+
</div>
|
863
|
+
END
|
864
|
+
expected = {
|
865
|
+
'foo/bar' => "<div><%= collection_select 'product', 'category_id', Category.find(:all), 'id', 'name', {}, :class => \"green\", :id => \"sel1\" %></div>"
|
866
|
+
}
|
867
|
+
assert_template_result expected, template, :template_pathname => 'one/two_three.four'
|
868
|
+
end
|
627
869
|
|
628
870
|
|
629
871
|
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.2.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.2.3
|
7
|
+
date: 2006-07-05 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
|
@@ -57,6 +57,9 @@ files:
|
|
57
57
|
- lib/masterview/filter_helpers.rb
|
58
58
|
- lib/masterview/directive_base.rb
|
59
59
|
- lib/masterview/keyword_expander.rb
|
60
|
+
- lib/masterview/attr_string_parser.rb
|
61
|
+
- lib/masterview/directive_registry.rb
|
62
|
+
- lib/masterview/masterview_info.rb
|
60
63
|
- lib/masterview/directives/global_inline_erb.rb
|
61
64
|
- lib/masterview/directives/link_to_if.rb
|
62
65
|
- lib/masterview/directives/preview.rb
|
@@ -81,8 +84,12 @@ files:
|
|
81
84
|
- lib/masterview/directives/link_to_remote.rb
|
82
85
|
- lib/masterview/directives/import.rb
|
83
86
|
- lib/masterview/directives/content.rb
|
87
|
+
- lib/masterview/directives/radio_button.rb
|
84
88
|
- lib/masterview/directives/text_area.rb
|
85
89
|
- lib/masterview/directives/image_tag.rb
|
90
|
+
- lib/masterview/directives/check_box.rb
|
91
|
+
- lib/masterview/directives/select.rb
|
92
|
+
- lib/masterview/directives/collection_select.rb
|
86
93
|
- lib/masterview/extras/app
|
87
94
|
- lib/masterview/extras/init_logger.rb
|
88
95
|
- lib/masterview/extras/watcher.rb
|
@@ -92,12 +99,15 @@ files:
|
|
92
99
|
- lib/masterview/extras/app/views
|
93
100
|
- lib/masterview/extras/app/controllers/masterview_controller.rb
|
94
101
|
- lib/masterview/extras/app/views/masterview
|
102
|
+
- lib/masterview/extras/app/views/layouts
|
95
103
|
- lib/masterview/extras/app/views/masterview/admin
|
96
104
|
- lib/masterview/extras/app/views/masterview/admin/view_rhtml.rhtml
|
97
105
|
- lib/masterview/extras/app/views/masterview/admin/list.rhtml
|
98
106
|
- lib/masterview/extras/app/views/masterview/admin/empty.rhtml
|
99
107
|
- lib/masterview/extras/app/views/masterview/admin/create.rhtml
|
100
108
|
- lib/masterview/extras/app/views/masterview/admin/features.rhtml
|
109
|
+
- lib/masterview/extras/app/views/masterview/admin/configuration.rhtml
|
110
|
+
- lib/masterview/extras/app/views/layouts/masterview_admin.rhtml
|
101
111
|
- Rakefile
|
102
112
|
- init.rb
|
103
113
|
- doc/stylesheets
|
@@ -145,6 +155,7 @@ files:
|
|
145
155
|
- test/unit/config_settings_test.rb
|
146
156
|
- test/unit/run_parser_test.rb
|
147
157
|
- test/unit/mio_test.rb
|
158
|
+
- test/unit/directive_helpers_parse_test.rb
|
148
159
|
- test/unit/directive_global_inline_erb_test.rb
|
149
160
|
- test/unit/directive_text_field_test.rb
|
150
161
|
- test/unit/directive_else_test.rb
|
@@ -179,6 +190,7 @@ files:
|
|
179
190
|
- test/unit/pathname_extensions_test.rb
|
180
191
|
- test/unit/string_hash_mio_test.rb
|
181
192
|
- test/unit/directive_image_tag_test.rb
|
193
|
+
- test/unit/directive_base_test.rb
|
182
194
|
- test/xtras/config_initialize_standalone.rb
|
183
195
|
- test/xtras/config-mv-logger_config.rb
|
184
196
|
- test/fixtures/configs
|